Unicode string changes when Unicode data is submitted from Chrome to ASP.Net page
I have strange problem with chrome encoding. IE, FF and Chrome encoding is set to UTF-8. When I have a long Unicode string submitted the value received in the server side is totally distorted in Chrome but is OK with FF and IE.
The textarea has a string comprised of characters 768 to 800. The form is submitted. I want to get the same string on the server-side. Distortion of the string happens only in Chrome
Here is the Code
<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);
}
The output is 768 to 799 in IE and FF. But completely messed up in Chrome.
Please help.
There is an issue with the Chrome browser. Please add this, I hope your problem will be resolved.
Page.Form.Attributes.Add("enctype", "multipart/form-data");
For a similar issue please see this article http://knowledgebaseworld.blogspot.com/2009/02/file-upload-not-working-with-update.html
精彩评论