I still haven't found an answer to my puzzlement about encoding
non-ASCII characters.  I've come to the conclusion that this isn't
specifically a Struts2 problem (so, I'll probably post on
stackoverflow for enlightenment), but for completeness's sake, here
are a few observations that may puzzle (or puzzled) other Strutsers:

In the following examples, I'm always encoding the string "Élizabeth"
(first character is an uppercase e-acute), using
java.net.URLEncoder.encode("Élizabeth", encoding) with a different
encoding each time;  then passing that encoded string in a URL
parameter (?foobar=encoded+string); then displaying said parameter in
JSP (with ${param.foobar}).

encoding name ==> URLEncoder.encode() ==> display in JSP:
UTF-8 ==> %C3%83%C2%89lizabeth ==> Élisabeth
UTF-16 ==> %FE%FF%00%C3%00%89lizabeth ==> þÿ�Ã�‰lisabeth
UTF-16LE ==> %C3%00%89%00lizabeth ==> Ã�‰�lisabeth
UTF-16BE ==> %00%C3%00%89lizabeth ==> �Ã�‰lisabeth
ISO-8859-1 ==> %C3%89lizabeth ==> Élizabeth
no encoding ==> %C3%3Flizabeth ==> Ã?lizabeth

Finally, as a reminder of my previous post, if I let <s:url> encode
the parameter:
==> %C3%89lizabeth ==> Élizabeth
(which is the least bad of the lot!)

All in all, the encoding that WOULD work (but which I cannot generate)
would be:  %C9lizabeth ==> Élizabeth (!!!)

If anyone has a clue on what's happening here, I'd love to read about it! ;)

Those tests were conducted with the setup mentioned in the previous
post in this thread, i.e:
> Tomcat 6.0.16, Java1.6.0_11, Struts 2.1.6
> <constant name="struts.i18n.encoding" value="UTF-8"/>
>
> <%@ page contentType="text/html;charset=UTF-8" language="java"
> pageEncoding="UTF-8" %>
> <?xml version="1.0" encoding="UTF-8"?>
> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
>
> I have a Tomcat encoding filter that sets each request's encoding to:
> "text/html;charset=UTF-8"
Firefox 3

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to