ASP.NET中的Unicode文本 [英] Unicode Text in ASP.NET

查看:192
本文介绍了ASP.NET中的Unicode文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的HTML页面上输入字段,用户可输入Unicode文本,比如我输入:ываываываываываыв

I have an input field on my html page where the user can enter Unicode text, for example i enter : ыва ыва ыва ыва ыва ыв

当的形式是贴出来,我检查张贴的值,并将其发布为:N <ваN <ваN <ваN <ва

When the form is posted, i check the value posted and it is posted as : ыва ыва ыва ыва

页面的内容类型被设置为:内容类型:text / html的;字符集= UTF-8

The content type of the page is set as :Content-Type: text/html; charset=utf-8

当我显示在网页上张贴的值,它显示为N <ваN <ваN <ваN <вÐ℃,而不是的ываываываываываыв。

When i display the posted value on the webpage, it shows as ыва ыва ыва ыва instead of ыва ыва ыва ыва ыва ыв.

我怎样才能解决这个问题才能正常显示?我需要做的转换编码?我相信,默认为C#字符串是UTF8,我的html页面字符集也被设置为UTF-8 - 所以不知道发生了什么事。

How can i fix this to display properly? Do i need to do convert the encoding ? I believe c# strings by default are utf8, and my html page charset is also set as utf-8 - so not sure what's going on.

更新:
这里是我的ASP页:

Update: Here's my ASP Page :

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="utf8.aspx.cs" Inherits="enterprise10._garbage.utf8"
    ValidateRequest="false" Theme="" EnableTheming="false" ResponseEncoding="utf-8" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">    
    <title></title>
</head>
<body>
    <form action="" method="post" runat="server">
    <asp:TextBox ID="UserInputText" runat="server"></asp:TextBox>
    <br />
    <asp:Label ID="UserInputLabel" runat="server" Text="Label"></asp:Label>
    <br />

       <input type="submit" />

    <hr />

<b>    Sample Text displays correctly on the page : </b><br />
    ыва ыва ыва ыва ыва ыв  



    </form>
</body>
</html>



代码背后:

protected void Page_Load(object sender, EventArgs e)
{
            UserInputLabel.Text = UserInputText.Text;
}



屏幕输出(IE9)的形式邮寄之前:

屏幕后表单提交

推荐答案

调整应用程序的编码,在在的web.config 文件中设置的请求和响应所需的编码(根据<&的System.Web GT;

Adjust the encoding of your application, in the web.config file set the desired encoding for requests and response (under <system.web>)

<globalization requestEncoding="utf-8" responseEncoding="utf-8" />

这篇关于ASP.NET中的Unicode文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆