Transfer Chinese Characters

Source: Internet
Author: User
Transfer:
String message = server. urlencode ("Welcome to ASP. NET! ");
Response. Redirect ("webform2.aspx? MSG = "+ message );
Resolution:
Server. urldecode (request. querystring ["MSG"])
If Javascript is used, escape () is used for encoding. server. urldecode () can also be used for decoding. Maybe they are encoded in the same way.

Use response. when the Redirect method transmits Chinese characters, it sometimes finds that the transmitted value is inconsistent with the received content. The received value may lose a few words or become a bunch of garbled characters. how can we ensure that the transmitted Chinese characters are correctly received?
The code for passing values on page a is as follows:

String message = server. urlencode ("Welcome to ASP. NET! ");
Response. Redirect ("webform2.asp? MSG = "+ message );

The code for page B's Acceptance value is as follows:

String message = server. urldecode (request. querystring ["MSG"]);

In some cases, the characters passed into garbled characters are caused by different encoding formats used by browsers and programs. asp. the default encoding format of the. NET application is "UTF-8 ". open the web. the following code is displayed in the config file:

<? XML version = "1.0" encoding = "UTF-8"?>

You can change the encoding format of an application by modifying the value of the encoding attribute. In some cases, you need to set this attribute to "gb2312" to understand Chinese garbled characters ".

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.