You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hertzel Karbasi - OPTinity eBusiness Solutions <he...@optinity.com> on 2002/02/13 21:32:34 UTC

Character Encoding wrong just for ApplicationResources!

Hello All

I have added  the following to JSP files
<META http-equiv="Content-Type" content="text/html, charset=UTF-8">
<%@ page contentType="text/html; charset=UTF-8" %>
<html:html locale="true">
Change the locale in an Action to iw_IL

And get:
Constant strings inserted in JSP in Hebrew are OK.
Just the Strings (<html:message> coming from Applicationresource are shown
as "??"
I have checked the messages in debug and found out that they come as "????"
from the resource.
The constant string inserted in the JSP in Hebrew just to check the browser
and they have been displayed right!

Any assistance will be appreciated.
Thanks
Hertzel


RE: Character Encoding wrong just for ApplicationResources!

Posted by Chris Birch <ch...@artlas.net>.
Hertzel,

The property files get loaded using ISO-8859-1 Encoding but they understand
unicode escapes.  Convert your file using the java tool (jdk/bin)
'native2ascii' and that should load the strings into the JVM correctly.

The only other possible problem occurs in some Containers (see Tagunov's doc
below for more detail) - The <%@ page contentType="text/html; charset=UTF-8"
%> gets converted into a setContentType() call on the response object, this
has to occur before the output writer is retrieved from the pageContext,
otherwise the default character encoding is used.  Some (web logic 6 amongst
others) set the content type after the writer is called thus rendering the
@page contentType directive useless!

Anton Tagunov's document is excellent and very comprehensive.

Hope this helps,
Chris.


-----Original Message-----
From: Hertzel Karbasi - OPTinity eBusiness Solutions
[mailto:hertzel@optinity.com]
Sent: 14 February 2002 08:40
To: Struts Users Mailing List
Cc: louis.leung@sun.com
Subject: Re: Character Encoding wrong just for ApplicationResources!


Thanks for your response.
But I have already saved the ApplicationResource file in Unicode but the
same results!!
I have tried saving the file in UTF-8 too but again the same results.

Any suggestions?
Thanks
Hertzel
----- Original Message -----
From: "Louis Leung" <lo...@sun.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, February 14, 2002 12:15 AM
Subject: Re: Character Encoding wrong just for ApplicationResources!


> or you can covert your properties file strings from native to unicode
using this
> method
>
> return new String(oldString.getBytes(), encoding);
>
> where encoding is the native encoding u used in your properties file
>
> more 'bout charset encoding/decoding on this page :
>
> http://tagunov.newmail.ru/i18n/i18n.html
>
> Hertzel Karbasi - OPTinity eBusiness Solutions wrote:
>
> > Hello All
> >
> > I have added  the following to JSP files
> > <META http-equiv="Content-Type" content="text/html, charset=UTF-8">
> > <%@ page contentType="text/html; charset=UTF-8" %>
> > <html:html locale="true">
> > Change the locale in an Action to iw_IL
> >
> > And get:
> > Constant strings inserted in JSP in Hebrew are OK.
> > Just the Strings (<html:message> coming from Applicationresource are
shown
> > as "??"
> > I have checked the messages in debug and found out that they come as
"????"
> > from the resource.
> > The constant string inserted in the JSP in Hebrew just to check the
browser
> > and they have been displayed right!
> >
> > Any assistance will be appreciated.
> > Thanks
> > Hertzel
> >
>
  ------------------------------------------------------------------------
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Character Encoding wrong just for ApplicationResources!

Posted by Hertzel Karbasi - OPTinity eBusiness Solutions <he...@optinity.com>.
Thanks for your response.
But I have already saved the ApplicationResource file in Unicode but the
same results!!
I have tried saving the file in UTF-8 too but again the same results.

Any suggestions?
Thanks
Hertzel
----- Original Message -----
From: "Louis Leung" <lo...@sun.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, February 14, 2002 12:15 AM
Subject: Re: Character Encoding wrong just for ApplicationResources!


> or you can covert your properties file strings from native to unicode
using this
> method
>
> return new String(oldString.getBytes(), encoding);
>
> where encoding is the native encoding u used in your properties file
>
> more 'bout charset encoding/decoding on this page :
>
> http://tagunov.newmail.ru/i18n/i18n.html
>
> Hertzel Karbasi - OPTinity eBusiness Solutions wrote:
>
> > Hello All
> >
> > I have added  the following to JSP files
> > <META http-equiv="Content-Type" content="text/html, charset=UTF-8">
> > <%@ page contentType="text/html; charset=UTF-8" %>
> > <html:html locale="true">
> > Change the locale in an Action to iw_IL
> >
> > And get:
> > Constant strings inserted in JSP in Hebrew are OK.
> > Just the Strings (<html:message> coming from Applicationresource are
shown
> > as "??"
> > I have checked the messages in debug and found out that they come as
"????"
> > from the resource.
> > The constant string inserted in the JSP in Hebrew just to check the
browser
> > and they have been displayed right!
> >
> > Any assistance will be appreciated.
> > Thanks
> > Hertzel
> >
>
  ------------------------------------------------------------------------
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Character Encoding wrong just for ApplicationResources!

Posted by Louis Leung <lo...@sun.com>.
or you can covert your properties file strings from native to unicode using this
method

return new String(oldString.getBytes(), encoding);

where encoding is the native encoding u used in your properties file

more 'bout charset encoding/decoding on this page :

http://tagunov.newmail.ru/i18n/i18n.html

Hertzel Karbasi - OPTinity eBusiness Solutions wrote:

> Hello All
>
> I have added  the following to JSP files
> <META http-equiv="Content-Type" content="text/html, charset=UTF-8">
> <%@ page contentType="text/html; charset=UTF-8" %>
> <html:html locale="true">
> Change the locale in an Action to iw_IL
>
> And get:
> Constant strings inserted in JSP in Hebrew are OK.
> Just the Strings (<html:message> coming from Applicationresource are shown
> as "??"
> I have checked the messages in debug and found out that they come as "????"
> from the resource.
> The constant string inserted in the JSP in Hebrew just to check the browser
> and they have been displayed right!
>
> Any assistance will be appreciated.
> Thanks
> Hertzel
>
>   ------------------------------------------------------------------------
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Character Encoding wrong just for ApplicationResources!

Posted by Louis Leung <lo...@sun.com>.
your properties file have to be written in Unicode encoding, not the native
encoding, or else java will screw your characters up, since java can only deal
with unicode

Hertzel Karbasi - OPTinity eBusiness Solutions wrote:

> Hello All
>
> I have added  the following to JSP files
> <META http-equiv="Content-Type" content="text/html, charset=UTF-8">
> <%@ page contentType="text/html; charset=UTF-8" %>
> <html:html locale="true">
> Change the locale in an Action to iw_IL
>
> And get:
> Constant strings inserted in JSP in Hebrew are OK.
> Just the Strings (<html:message> coming from Applicationresource are shown
> as "??"
> I have checked the messages in debug and found out that they come as "????"
> from the resource.
> The constant string inserted in the JSP in Hebrew just to check the browser
> and they have been displayed right!
>
> Any assistance will be appreciated.
> Thanks
> Hertzel
>
>   ------------------------------------------------------------------------
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>