Garbled characters occur in program development:
1: Use JS functions as URL parameterized jump, such as window. open (URL). At this time, the URL is a URL with parameters spliced, including characters other than ASCII, then an error occurs when receiving the page, this part of Non-ASCII encoding is garbled.
2: Use the server-side jump method, such as respon. Redirect to jump to a URL with parameters. In this case, problems may also occur due to browser compatibility issues.
Solution of Case 1:
1: In the default web. config file, <globalization requestencoding = "UTF-8" responseencoding = "UTF-8"/>
Modify the default format to <globalization fileencoding = "gb2312" requestencoding = "gb2312" responseencoding = "gb2312"/> to solve the problem.
2: encode the parameterized URL transmitted by JS
For example:
Function jumptopage (){
VaR url = encodeuri ("Accept encoding page (get passed parameters). aspx ");
VaR paramspart = encodeuri ("? Name = Haha & adddress = People's Republic of China ")
// Var paramspart = "? Name = "+ escape ('Ha) +" & adddress = "+ escape ('People's Republic of China') + "";
VaR totolurl = URL + paramspart;
Window. Location. href = totolurl;
}
Function jumptopageescape (){
VaR url = "reciveparamspage. aspx ";
VaR paramspart = "? Name = "+ escape ('Ha) +" & adddress = "+ escape ('People's Republic of China') + "";
VaR totolurl = URL + paramspart;
Window. Location. href = totolurl;
}
VaR url = "A. aspx? Cd = "+ hotelcd +" & name = "+ escape (name) + "";
Accept page, normal acceptance or server. urldecode (request. querystring ["name"]. tostring.
Solution for Case 2:
Before the response. Redirect jump, call server. urlencode to encode the URL, and use server. urldecode to decode the URL on the acceptance page.