我的html页面上有一个输入字段,用户可以在其中输入Unicode文本,例如我输入:ываываываываываыв
当表格张贴时,我检查张贴的价值,并将其公布为:Ñ<ваÑ<ваÑ<ваÑ<²²°°
页面的内容类型设置为:Content-Type:text/html; 字符集= utf-8的
当我显示在网页上张贴值,它示出了当n <ваN <ваN <ваN <ва而不是ываываываываываыв.
我该如何解决这个问题才能正常显示?我需要转换编码吗?我相信c#字符串默认是utf8,我的html页面字符集也设置为utf-8 - 所以不确定发生了什么.
更新: 这是我的ASP页面:
<%@ 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>
Run Code Online (Sandbox Code Playgroud)
代码背后:
protected void Page_Load(object sender, EventArgs e)
{
UserInputLabel.Text = UserInputText.Text;
}
Run Code Online (Sandbox Code Playgroud)
屏幕输出(IE9)在表格发布之前:

表格发布后筛选出来

Bru*_*oLM 10
调整应用程序的编码,在web.config文件中设置所需的请求和响应编码(下<system.web>)
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11783 次 |
| 最近记录: |