How to solve the problem of Chinese garbled characters transmitted between pages

Source: Internet
Author: User
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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.