当Unicode数据从Chrome提交到ASP时,Unicode字符串会发生变化.网络页面

Unicode string changes when Unicode data is submitted from Chrome to ASP.Net page

本文关键字:Unicode 变化 网络 字符串 Chrome 数据 提交 ASP      更新时间:2023-09-26

我对chrome编码有奇怪的问题。IE, FF和Chrome的编码设置为UTF-8。当我有一个长Unicode字符串提交在服务器端收到的值在Chrome中是完全扭曲的,但是OK与FF和IE。

textarea是一个由768到800字符组成的字符串。提交表单。我想在服务器端得到相同的字符串。字符串失真只发生在Chrome

下面是代码

<form id="form1" runat="server">
    <div>
    <textarea id="ta1" runat="server" rows="10" cols="50"></textarea>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</form>
<sccript>
    var ta1 = document.getElementById('ta1');
        var s = '';
        for (var i = 768; i < 800; i++)
        {
            s += String.fromCharCode(i);
        }
        ta1.value = s;
</script>
---------------------
Code behind
--------------------
protected void Button1_Click(object sender, EventArgs e)
{
string s = ta1.Value;
string s2 = "";
for(int i=0;i<s.length;i++)
{
   s2 += "i:" + Convert.ToInt32(s[i]) + "<br/>";
}
Response.Write(s2);
}

IE和FF输出为768 ~ 799。但是在Chrome中完全搞砸了。

请帮。

Chrome浏览器有问题。请加上这一点,我希望你的问题将得到解决。

Page.Form.Attributes.Add("enctype", "multipart/form-data");

类似问题请参阅本文http://knowledgebaseworld.blogspot.com/2009/02/file-upload-not-working-with-update.html