How to solve the problem of transmitting Chinese garbled between the page
HBZXF (A Ho) http://www.cnblogs.com/hbzxf
Sometimes we need to transfer Chinese between the page, but .NET models are UTF-8 for our encoding format for us in WebConfig, so the corresponding acceptance will be garbled information when transmitting Chinese. How to solve this problem, we can use two methods.
Change the encoding method in WebConfig, as follows:
1. Put the code in your web.config
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????? RequestentEncoding = "UTF-8"
??????????? responseEncoding = "UTF-8"
?? />
Change to
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????? RequestentEncoding = "GB2312"
??????????? responseEncoding = "GB2312"
?? />
The second method:
First encode before passing: Example: string xm = server.urlencode ("Zhang 3"); Response.Redirect ("B.ASPX? XM =" xm); then decoding: string xm = server. URLDECode ("xm"); there is another thing that there will be a problem with the Base64 when we make a mail system, often garbled, I solved this, try it. code show as below:
String encodedmail = "Mail content"; Byte [] barr = convert.FromBase64String (encodedmail); string decodedmail = system.text.Encoding.Getencoding ("GB2312"). GetString (Barr);
Some small problems that the author experienced itself, you may wish to let everyone see, and you.
Because the author is limited, the code is omissions, please point out, the code is chaotic, please forgive me!
?