I have an input field on my html page where the user can enter Unicode text, for example i enter : ыва ыва ыва ыва ыва ыв
When the form is posted, i check the value posted and it is posted as : ыва ыва ыва ыва
The content type of the page is set as :Content-Type: text/html; charset=utf-8
When i display the posted value on the webpage, it shows as ыва ыва ыва ыва instead of ыва ыва ыва ыва ыва ыв.
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.
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>
Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
UserInputLabel.Text = UserInputText.Text;
}
Screen Output (IE9) Before form post:
Screen Out after form post
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With