问题
Like the problem described by title, my problem is when I read the Http header that returned from the server in the android programs , it appears Disorderly code of strings, so, what I don't know is, what kind of charset the server used to encoding the http response Headers ?and what charset the andorid used to decode the http response headers? How do I escape or deal the Garbled?
回答1:
Since HTTP Headers are MIME, see RFC 822 where it is defined as ASCII.
3.1.2. STRUCTURE OF HEADER FIELDS
Once a field has been unfolded, it may be viewed as being composed of a field-name followed by a colon (":"), followed by a field-body, and terminated by a carriage-return/line-feed. The field-name must be composed of printable ASCII characters (i.e., characters that have values between 33. and 126., decimal, except colon). The field-body may be composed of any ASCII characters, except CR or LF. (While CR and/or LF may be present in the actual text, they are removed by the action of unfolding the field.)
Then RFC 2047
describes extensions to RFC 822 to allow non-US-ASCII text data in Internet mail header fields
来源:https://stackoverflow.com/questions/9416470/does-somebody-know-what-charset-the-http-headers-used-to-encode