How to solve the problem of Chinese garbled characters transmitted between pages
Hbzxf (Hao)
Http://www.cnblogs.com/hbzxf
Sometimes we need to transmit Chinese characters between pages,. NET mode recognizes that the encoding format we set up in Webconfig is UTF-8, so it becomes garbled during Chinese transmission, and the corresponding accept will also be garbled information. How can we solve this problem, we can use two methods.
Change the encoding method in Webconfig as follows:
1. encode the code in your web. config
<Globalization
RequestEncoding = "UTF-8"
ResponseEncoding = "UTF-8"
/>
Change
<Globalization
RequestEncoding = "gb2312"
ResponseEncoding = "gb2312"
/>
Method 2:
First, encode the code before transmission: for example:
String xm = Server. URLEncode ("James ");
Response. Redirect ("B. aspx? Xm = "+ xm );
Then decode on the receiving page:
String xm = Server. URLDecode (Requext. querystring ("xm "));
Another thing to say is that when we create an email system, there will be a problem of receiving base64, which often produces garbled code. I am doing this, so try it. The Code is as follows:
String encodedMail = "email content ";
Byte [] barr = Convert. FromBase64String (encodedMail );
String decodedMail = System. Text. Encoding. GetEncoding ("gb2312"). GetString (barr );
These are some of the minor issues that the author has experienced. You may wish to write them out for your reference.
Due to the limited level of the author and code omissions, please give me some advice. The code is messy. Please forgive me!