Cause
There are two main reasons
1. The default character encoding of data returned by xtmlhttp is UTF-8. If the foreground page is gb2312 or other encoding data, garbled characters are generated.
2. The default character encoding for data submitted by the POST method is UTF-8. if the background is gb2312 or other encoding data, garbled characters are generated.
Solution
Further sorting
Recommended method. The front-end uses UTF-8 encoding, which saves a lot of trouble and fundamentally solves the garbled problem. the advantage is that it is highly efficient and conforms to the current format. UTF-8 encoding itself is a relatively good encoding with no language restrictions. disadvantage: You can only call your own background encoding or other UTF-8 encoding.
Front-end Code <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
Add the following to the first line of ASP in the background:CodeProgram code <% @ Language = "JavaScript" codePage = "65001" %>
<% Response. charset = "UTF-8"; %>
<% Session. codePage = 65001; %>
If the background contains HTML code, ensure that the program code <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
The remedy is to perform encoding conversion. You can perform encoding conversion on the client or the server. The advantage is that there are no restrictions and the disadvantage is low efficiency.
Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 772650
Related Article :
- Generation and solution of page garbled characters in PHP and MySQL development phpme
- Use JScript to encode form data with UTF-8 (in desperation) flylyke
- A: "messageresource garbled in Linux" lovetide
- On the issue of coding in J2EE development, UTF-8 is used to adapt to the multi-language J2EE development 2006-04-21 Faust
- SQL Server Chinese garbled Analysis Solution: caihualin