ASP + ACCESS database Chinese garbled Problem Solution

Source: Internet
Author: User
ASP. NET Chinese garbled Problem Solution
Problem
1: The ASPX page transmits Chinese parameters to the aspx
2: upload Chinese parameters to ASP on the ASPX page

There are generally three solutions:

There are generally three methods:
1. Set the Web. config file

<System. Web>
......
<Globalization requestencoding = "gb2312" responseencoding = "gb2312" Culture = "ZH-CN" fileencoding = "gb2312"/>
......
</System. Web>

2. Before passing Chinese characters, encode the Chinese parameters to be passed and decode them upon receiving them.
> Transfer

String name = "Chinese parameter ";
Response. Redirect ("B. aspx? Name = "+ server. urlencode (name ));
> Receive
String name = request. querystring ["name"];
Response. Write (server. urldecode (name ));

3. If a Chinese parameter is transferred from the. html file to the. aspx file (that is, URL conversion is not performed using the Redirect () method from the background ). Similarly, the passed Chinese parameters must be encoded and decoded upon receiving.
> Transfer

<Script language = "JavaScript">
Function gourl ()
{
VaR name = "Chinese parameter ";
Location. href = "B. aspx? Name = "+ escape (name );
}

<Body onclick = "gourl ()">
> Receive
String name = request. querystring ["name"];
Response. Write (server. urldecode (name ));

In general. Set the Web. config file. However, if you use JavaScript to call the WebService method (passing Chinese parameters to WebService ). The Web. config file is invalid.

Or use

Response. Redirect ("test1.aspx? 111 = "+ system. Web. httputility. urlencode (" People's Republic of China "); // recommended

Finally, it would be easier to get Chinese parameters from other pages without garbled characters.

String message ="

Screen. Width-500) This. style. width = screen. Width-500; "align =" absbottom "border =" 0 ">

http: // address of the return value of a page to be obtained "
httpwebrequest myhttpwebrequest = (httpwebrequest) webrequest. create (Message); // send the request
httpwebresponse myhttpwebresponse = (httpwebresponse) myhttpwebrequest. getresponse (); // accept the request
stream receivestream = myhttpwebresponse. getresponsestream ();
streamreader readstream = new streamreader (receivestream, system. text. encoding. getencoding ("gb2312");
returnvalue = readstream. readtoend (); // This is the returned result of the return value of the page to be retrieved.

Related Article

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.