Today, the children wrote a program and garbled characters. Let's share the solution process:
For convenience, the environment is simplified, vs.net 2003, jquery-1.3.2.js, Web Service call
Simple requests, simple responses, but garbled
Why?
The reason for garbled characters is very simple. It is nothing more than an error in the encoding table. For example, if big5 characters are passed, UTF-8 or UTF-8 is used for receiving the code, but gb2312 is used for decoding.
Okay. Check whether the garbled characters are generated during the request.
So what I sent is garbled?
Open test.txt under C:/tmp/
What code is this? Guess it?
It seems that the client is correct, and the server is correct. It should be Asp.net's wrong encoding. In the httprequest class, find out if there are any related encoding attributes.
Look at web. config.
Test the modification to UTF-8.
The reason is found successfully. It seems that the client uploads UTF-8 and the server receives big5 messages.
However, this project cannot be solved in this way, because the old project has been running for a long time and may affect other previous programs. Change the client and set the request attribute to UTF-8, make Asp.net unconfused
Modify Ajax requestCode, Set charset attributes
The problem was solved. However, jquery was also used in vs2005 recently, and no garbled characters were found. It may be that vs2005 has already set the default value to UTF-8. (If you have time, find out where the default value is, or let us know about that Tx)
Vs. net2003 is the encoding of the Local Operating System by default, such as big5 and gb2312, so garbled characters often occur.
In addition, you can share a simple method to view Garbled text files.
For some text files (such as aspx and CS) that do not end with txt, you can change the suffix to TXT first, and then open ie. Otherwise, ie will not recognize it and download it directly.
Too many images. Please forgive us for the slow speed of TX ~~