-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
André,
As Chuck points out, I really meant to encode using UTF-8. The result is
always an US-ASCII string, as per the java.net.URLEncode documentation
(really the URL Spec).
On 3/18/2009 6:51 PM, André Warnier wrote:
> If the string contained any Japanese characters, what would happen is :
> - the string would first be converted to ASCII. Since ASCII does not
> support Japanese characters, you would get a string with plenty of "???"
> characters (unless java.net.URLEncoder triggers an exception for that).
> - then this string would be URL-encoded, converting the embedded "???"
> into their percent-encoded representation.
> ...and there is thus no chance at all that the server would ever be able
> to retrieve the original Japanese characters.
Right. Since I had this backward, what should really happen is:
UTF-8 is used to encode the Japanese characters into a series of bytes
which are then %-escaped and sent as a valid US-ASCII string.
> Then, the server application would presumably obtain the content of this
> header via a request.getHeader("X-header-name"), and receive a Unicode
> string containing "foobar%45%67%65%43%45%45%78%69...".
> It would then decode it using java.net.URLEncoder.decode(text, "UTF-8"),
> in order to obtain back the original string.
> And it would work fine.
Exactly. Hopefully, the OP will read the entire thread instead of just
taking my bad advice :)
> But in a totally non-portable way (meaning just between that client and
> that application), and with just too many conditional tenses to make
> this comfortable.
Agreed. This is why I recommended using HTTP POST for such data (I know,
I know... don't get you started on POST!).
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAknCYfgACgkQ9CaO5/Lv0PBh7wCeI0GcB2TWE5174j3pT1sFX2gF
1BMAnA7fqXRXceapcUQQ+IQfk9oaDwl2
=4ByH
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]