On Wed, Oct 15, 2003 at 04:17:40PM -0400, James Pan wrote:
> Hi,
>
> I'm a bit overwhelmed by the info here... just to clarify a couple of things:
> >> 4) I make sure that this gets called somewhere on the request object:
> >> req.setCharacterEncoding("UTF-8");// or UTF8, can't remember
>
> This would be the same as
>
> <%@ page contentType="text/html; charset=UTF-8"%>, no?
>
> Can I call setCharacterEncoding(str) over and over with different encoding strings?
There're two problems:
1) returning readable results
2) correctly determining/setting request parameters encoding
If your page needs to render multilanguage content, the best way to do
it is to render it in UTF-8:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="encoding-that-is-used-to-write-pages" %>
All the browsers I've tested (except for, probably, lynx) encode request
using the page encoding. So if your page is rendered in utf-8, you
need to explicitly specify that all request parameters are in utf-8.
It can be done with req.setCharacterEncoding("UTF-8").
I am using tomcat, and AFAIK there's no way to set default input
encoding in web.xml, so the best way to do it is via filter
(e.g., see http://www.struts.ru/addition/SetCharacterEncodingFilter.java).
This will make sure that the encoding is set before request parameters are
accessed by WebWork or struts or something else. (Actually, I haven't
used it with WebWork yet -- I am still in progress of switching from
struts :))
See also: http://www.jguru.com/faq/view.jsp?EID=137281
[...]
> When I bring this page up in IE, I get this junk in the browser. I had to manually
> set the encoding to UTF-8 in order to see them displayed correctly.
>
> HOWEVER, if I change the charset in <%@ page contentType="text/html;
> charset=UTF-8"%> I get junk that simply cannot be displayed correctly.
>
> Does this mean I have UTF-8 characters being encoded in ISO-8859-1, in essense
> "double-encoding"?? And how can I avoid this??
As someone else has pointed out, you probably should specify your
file encoding with the @page directive (as someone else has already
pointed out). It is also possible that your web server is setting the
content-type in response headers, overriding content-type specified by
the @page directive.
(If you're using apache+tomcat, look for AddDefaultCharset option in apache
configuration.)
Hope this helps,
Sergei
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork