One of the most common problems in Ajax is that the server's response containing Chinese characters is garbled after being encoded by XMLHTTP. This problem also exists in Atlas.
This is not a big problem, but sometimes it is very troublesome. Now I have two solutions. If you need them, please refer to them.
1). Modify the Web. config encoding
<Globalization requestencoding = "UTF-8" responseencoding = "UTF-8"/> if your encoding is gb2312, this change may cause garbled characters on other pages, then you have to unify the UTF-8 encoding on the entire site.
2). encode the submitted string (recommended)
Static String Formatencode ( String Str)
{
Byte[] Buffer=System. Text. encoding. Default. getbytes (STR );
ReturnSystem. Text. encoding. utf8.getstring (buffer );
}
This method is used to format the input string and then submit it.
The advantage of this method is that there is no need to modify the page encoding, and there is a low probability of problems after modification;
The disadvantage is that the encoding is performed once each commit, which degrades the performance. However, it is expected that the data submission is much less than the display, so the performance impact is limited.