开发者

Chinese encoding issue

开发者 https://www.devze.com 2023-03-17 18:31 出处:网络
I send some Chinese character via query string but the page that receives them does not display them correctly. In particular, it must display them in <input type=\"text\" />. How to settl开发

I send some Chinese character via query string

Chinese encoding issue

but the page that receives them does not display them correctly. In particular, it must display them in <input type="text" />. How to settl开发者_高级运维em down the problem?


You will want to use UTF-8:

Response.Codepage = 65001
Response.CharSet = "UTF-8"

Change your input tag to something like:

<input type="text" value="<%=Server.HTMLEncode(Request.QueryString("word"))%>" />

Server.HTMLEncode will prevent XSS attacks and also help browsers render the correct characters.

If you still have issues, you will want to add the following in your before the </head> in your HTML.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
0

精彩评论

暂无评论...
验证码 换一张
取 消