开发者

Asian characters in IE 8 get garbled in Server; is this due to HTTP header Content-Type?

开发者 https://www.devze.com 2023-01-18 23:53 出处:网络
One of the request parameters in an http request made by the client contains Japanese characters. If I make this request in Firefox and look at the parameter as soon as it reaches the server by debugg

One of the request parameters in an http request made by the client contains Japanese characters. If I make this request in Firefox and look at the parameter as soon as it reaches the server by debugging in Eclipse, the characters look fine. If I do the same request using IE 8, the characters get garbled when I look at them at the same point in the server code (they are fine in both browsers, though). I have examined the POST requests made by both browsers, and they both pass the same sequence of characters, which is:

%2C%E3%81%9D%E3%81%AE%E4%BB%96

I am therefore thinking that this has to do with the encoding. If I look at the HTTP headers of the request, I notice the following differences. In IE:

Content-Type: application/x-www-form-urlencoded
Accept: */*

In Firefox:

Content-Type application/x-www-form-urlencoded; charset=UTF-8
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7

I'm thinking that the IE 8 header doesn't state the UTF-8 encoding explicitly, even though it's specified in the meta tag of the HTML document. I am not sure if this is the proble开发者_开发问答m. I would appreciate any help, and please do let me know if you need more information.


Make sure the page that contains the form has UTF-8 as charset. In IE's case, the best thing to make sure of this is by sending a HTTP header ('Content-Type: text/html; charset=utf-8') and adding a meta http-equiv tag with the content type/charset to your html (I've seen this actually matter, even when the appropriate header was sent).

Second, your form can also specify the content type:

<form enctype="application/x-www-form-urlencoded; charset=utf-8>
0

精彩评论

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

关注公众号