On 9/20/06, Marius Feraru <[EMAIL PROTECTED]> wrote:

> It's useless to try encoding HTTP headers in any way, as no HTTP spec
> (rfc2616, rfc1945, erratas, etc) specify any encoding to be necessary.

But RFC 2616 says

Words
of *TEXT MAY contain characters from character sets other than ISO-
8859-1 only when encoded according to the rules of RFC 2047

Doesn't that mean, that one may use quoted-printable encoding as
described in RFC 2047?

> More than that, I already described that Gecko parses headers correctly
> (nsHttp module), it's just some other part of their toolkit that messes
> with those headers before letting JS using them. :(

Just to clear this up:

Sending the ß character
X-JSON (utf-8 encoded value) = C3 9F
X-JSON-UCS (equals ISO-8859-1 in this case) = DF

Firefox has to assume both headers contain ISO-8859-1 encoded values

X-JSON = 2 character string C3 9F = ß in ISO-8859-1
X-JSON-UCS = 1 character string DF = ß in ISO-8859-1

Pass the values to JS as

X-JSON = "\u00C3\u009F" = ß in UTF-8
X-JSON-UCS = "\u00DF" = ß in UTF-8

Seems consistant with the observations and what it is supposed to do
according to the RFC.

Now as to the debugger messages as in
- -1210520688[9c18b48]:   X-JSON: {"a":"ß","_":"","b":"ç"}

Firefox expects the header to be ISO-8859-1 and it cannot know that
the data is actually UTF-8 encoded. Therefore it cannot know that C3
9F is ß. So how can it be able to show "ß" in the above output? It
looks like it is just the display system that assumes UTF-8 data, gets
C3 9F and displays a "ß" where as Firefox internaly deals with the
byte sequence that it assumes to be a ISO-8859-1 encoded string.

Your tests show that IE6 correctly retrieves a UTF-8 encoded header?
Then it should wrongly decode the ISO-8859-1 equivalent value in the
X-JSON-UCS header as either C3 9F or DF can be "ß", but not both, no?

Looks like one needs a function that takes the result from
getResponseHeader() and reconstructs the UTF-8 encoded string from the
bytes returned by charCodeAt().

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to