You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sathish Kumar <sa...@gmail.com> on 2012/06/29 12:35:03 UTC
Issue with Chinese Charctors
Hi,
In our struts 2 project, we support Chinese language. While we save Chinese
text in forms we see junk characters getting saved.
While investigating, we found this link
http://www.mkyong.com/struts2/struts-2-chinese-localization-issue/
As per this,
At the top of the JSP Page, we need to include
*<%@ page contentType=”text/html;charset=UTF-8″ %>*
Now the issue is, it is only possible with JSP pages. But in our case, we
use free marker as our result type.
What is the coresponding freemarker sysntax for the above JSP code?
Any help here will be greatly helpful to us !!
Regards,
Sathish Kumar T
RE: Issue with Chinese Charctors
Posted by Martin Gainty <mg...@hotmail.com>.
this issue was reported a ways back http://mail-archives.apache.org/mod_mbox/struts-user/201002.mbox/%3C53ee77ab1002070842x50988007h61fc91dee0239fb7@mail.gmail.com%3E
something to check:0)be sure use a charset which will support your locale (zh)..be mindful of DBCS support
1)set locale to chinese e.g. zh2a)use locale specific text properties e.g. MessageResources_zh.properties this is going to require a string by string translation for each characterproperty1error1=\u30d7\u30ed\u30d1\u30c6\u30a3 1, \u30a8\u30e9\u30fc 1from Brians blogI started creating a new file using the Notepad editor on Windows XP . The
file is then saved as type "Unicode Big Endian"
Next, using the native2ascii utility from JDK 1.4 SDK, I use the following
command to convert this file to an ASCII file:
native2ascii -encoding UnicodeBig CustomerResources_zh.ucd
MessageResources_zh.properties
2b)confirm MessageResources are being references by Struts in struts-config.xml e.g.<message-resources parameter="MessageResources"/> Input and Display considerations:
set IME to properly input chinese characters (keyboard) if im not mistaken windows handles IME and display under Control-Panel "Region and Language" Browsers have specific procedures to change display to mandarin e.g.internet explorer, Tools --> Internet Options --> Languages tab, I
added the language "Chinese (Hong Kong S.A.R.) [zh-HK]"
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> From: mcucchiara@apache.org
> Date: Fri, 29 Jun 2012 12:42:17 +0200
> Subject: Re: Issue with Chinese Charctors
> To: user@struts.apache.org
>
> IIRC there is a way to configure encoding inside freemarker.properties.
> From the struts side there is also a struts.i18n.encoding properties which
> might be useful.
>
>
> Twitter :http://www.twitter.com/m_cucchiara
> G+ :https://plus.google.com/107903711540963855921
> Linkedin :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
>
>
> On 29 June 2012 12:35, Sathish Kumar <sa...@gmail.com>wrote:
>
> > Hi,
> >
> > In our struts 2 project, we support Chinese language. While we save Chinese
> > text in forms we see junk characters getting saved.
> >
> > While investigating, we found this link
> >
> > http://www.mkyong.com/struts2/struts-2-chinese-localization-issue/
> >
> > As per this,
> >
> > At the top of the JSP Page, we need to include
> >
> > *<%@ page contentType=”text/html;charset=UTF-8″ %>*
> >
> > Now the issue is, it is only possible with JSP pages. But in our case, we
> > use free marker as our result type.
> >
> > What is the coresponding freemarker sysntax for the above JSP code?
> >
> > Any help here will be greatly helpful to us !!
> >
> > Regards,
> > Sathish Kumar T
> >
Re: Issue with Chinese Charctors
Posted by Maurizio Cucchiara <mc...@apache.org>.
IIRC there is a way to configure encoding inside freemarker.properties.
>From the struts side there is also a struts.i18n.encoding properties which
might be useful.
Twitter :http://www.twitter.com/m_cucchiara
G+ :https://plus.google.com/107903711540963855921
Linkedin :http://www.linkedin.com/in/mauriziocucchiara
Maurizio Cucchiara
On 29 June 2012 12:35, Sathish Kumar <sa...@gmail.com>wrote:
> Hi,
>
> In our struts 2 project, we support Chinese language. While we save Chinese
> text in forms we see junk characters getting saved.
>
> While investigating, we found this link
>
> http://www.mkyong.com/struts2/struts-2-chinese-localization-issue/
>
> As per this,
>
> At the top of the JSP Page, we need to include
>
> *<%@ page contentType=”text/html;charset=UTF-8″ %>*
>
> Now the issue is, it is only possible with JSP pages. But in our case, we
> use free marker as our result type.
>
> What is the coresponding freemarker sysntax for the above JSP code?
>
> Any help here will be greatly helpful to us !!
>
> Regards,
> Sathish Kumar T
>
Re: Issue with Chinese Charctors
Posted by Sathish Kumar <sa...@gmail.com>.
Wav i did this and it shows proper Chinese text in struts 2 text box
[@s.textfield name="entity.label" key="label" escape="true"/]
But then :( .... now i get junk characters in plain HTML places where i use
these labels
is it possible to set this escaping flag from action so that we set
escaping flag only when actions class results html form ..
On Fri, Jun 29, 2012 at 6:12 PM, Maurizio Cucchiara
<mc...@apache.org>wrote:
> This is the escape attribute (true by default), and what you see should be
> the html encoding for the corresponding encoded value.
> Try to set escape to false
>
> Sent from my mobile device, so please excuse typos and brevity.
>
> Maurizio Cucchiara
> Il giorno 29/giu/2012 12.56, "Sathish Kumar" <
> sathishkumar.thiyagarajan@gmail.com> ha scritto:
>
> > Hi Dave & Maurizio,
> >
> > Thanks a lot for such a quick response !!!
> >
> > I applied below properties in struts and freemarker configurations
> >
> > struts.properties
> > ----------------------
> > struts.i18n.encoding=UTF-8
> >
> > freemarker.properties
> > ----------------------------
> > default_encoding=UTF-8
> > template_update_delay=5
> > locale=no_NO
> >
> > This almost solved the problem .. now data is getting saved and rendered
> > properly ( in plain HTML tags ) ..... but when we edit this data in the
> > form using
> >
> > [@s.textfield name="localesensitivetext" key="localesensitivetext"/]
> >
> > texy field contains something like தமிழ்
> > instead of actual text ....
> >
> > Thanks & Regards,
> > Sathish Kumar T.
> >
> > On Fri, Jun 29, 2012 at 4:11 PM, Dave Newton <da...@gmail.com>
> > wrote:
> >
> > > On Fri, Jun 29, 2012 at 6:35 AM, Sathish Kumar wrote:
> > >
> > > > In our struts 2 project, we support Chinese language. While we save
> > > Chinese
> > > > text in forms we see junk characters getting saved.
> > > >
> > > > While investigating, we found this link
> > > >
> > > > http://www.mkyong.com/struts2/struts-2-chinese-localization-issue/
> > > >
> > > > As per this,
> > > >
> > > > At the top of the JSP Page, we need to include
> > > >
> > > > *<%@ page contentType=”text/html;charset=UTF-8″ %>*
> > > >
> > > > Now the issue is, it is only possible with JSP pages. But in our
> case,
> > we
> > > > use free marker as our result type.
> > > >
> > > > What is the coresponding freemarker sysntax for the above JSP code?
> > > >
> > >
> > > Did you try setting the encoding in the `freemarker.properties` file as
> > per
> > > the freemarker support docs [1]?
> > >
> > > This isn't necessarily what your issue is, though, if you're talking
> > > specifically about *saving* I18N data from forms, although it could be
> > > related.
> > >
> > > Dave
> > >
> > > [1] http://struts.apache.org/2.x/docs/freemarker-support.html
> > >
> >
>
Re: Issue with Chinese Charctors
Posted by Maurizio Cucchiara <mc...@apache.org>.
This is the escape attribute (true by default), and what you see should be
the html encoding for the corresponding encoded value.
Try to set escape to false
Sent from my mobile device, so please excuse typos and brevity.
Maurizio Cucchiara
Il giorno 29/giu/2012 12.56, "Sathish Kumar" <
sathishkumar.thiyagarajan@gmail.com> ha scritto:
> Hi Dave & Maurizio,
>
> Thanks a lot for such a quick response !!!
>
> I applied below properties in struts and freemarker configurations
>
> struts.properties
> ----------------------
> struts.i18n.encoding=UTF-8
>
> freemarker.properties
> ----------------------------
> default_encoding=UTF-8
> template_update_delay=5
> locale=no_NO
>
> This almost solved the problem .. now data is getting saved and rendered
> properly ( in plain HTML tags ) ..... but when we edit this data in the
> form using
>
> [@s.textfield name="localesensitivetext" key="localesensitivetext"/]
>
> texy field contains something like தமிழ்
> instead of actual text ....
>
> Thanks & Regards,
> Sathish Kumar T.
>
> On Fri, Jun 29, 2012 at 4:11 PM, Dave Newton <da...@gmail.com>
> wrote:
>
> > On Fri, Jun 29, 2012 at 6:35 AM, Sathish Kumar wrote:
> >
> > > In our struts 2 project, we support Chinese language. While we save
> > Chinese
> > > text in forms we see junk characters getting saved.
> > >
> > > While investigating, we found this link
> > >
> > > http://www.mkyong.com/struts2/struts-2-chinese-localization-issue/
> > >
> > > As per this,
> > >
> > > At the top of the JSP Page, we need to include
> > >
> > > *<%@ page contentType=”text/html;charset=UTF-8″ %>*
> > >
> > > Now the issue is, it is only possible with JSP pages. But in our case,
> we
> > > use free marker as our result type.
> > >
> > > What is the coresponding freemarker sysntax for the above JSP code?
> > >
> >
> > Did you try setting the encoding in the `freemarker.properties` file as
> per
> > the freemarker support docs [1]?
> >
> > This isn't necessarily what your issue is, though, if you're talking
> > specifically about *saving* I18N data from forms, although it could be
> > related.
> >
> > Dave
> >
> > [1] http://struts.apache.org/2.x/docs/freemarker-support.html
> >
>
Re: Issue with Chinese Charctors
Posted by Sathish Kumar <sa...@gmail.com>.
Hi Dave & Maurizio,
Thanks a lot for such a quick response !!!
I applied below properties in struts and freemarker configurations
struts.properties
----------------------
struts.i18n.encoding=UTF-8
freemarker.properties
----------------------------
default_encoding=UTF-8
template_update_delay=5
locale=no_NO
This almost solved the problem .. now data is getting saved and rendered
properly ( in plain HTML tags ) ..... but when we edit this data in the
form using
[@s.textfield name="localesensitivetext" key="localesensitivetext"/]
texy field contains something like தமிழ்
instead of actual text ....
Thanks & Regards,
Sathish Kumar T.
On Fri, Jun 29, 2012 at 4:11 PM, Dave Newton <da...@gmail.com> wrote:
> On Fri, Jun 29, 2012 at 6:35 AM, Sathish Kumar wrote:
>
> > In our struts 2 project, we support Chinese language. While we save
> Chinese
> > text in forms we see junk characters getting saved.
> >
> > While investigating, we found this link
> >
> > http://www.mkyong.com/struts2/struts-2-chinese-localization-issue/
> >
> > As per this,
> >
> > At the top of the JSP Page, we need to include
> >
> > *<%@ page contentType=”text/html;charset=UTF-8″ %>*
> >
> > Now the issue is, it is only possible with JSP pages. But in our case, we
> > use free marker as our result type.
> >
> > What is the coresponding freemarker sysntax for the above JSP code?
> >
>
> Did you try setting the encoding in the `freemarker.properties` file as per
> the freemarker support docs [1]?
>
> This isn't necessarily what your issue is, though, if you're talking
> specifically about *saving* I18N data from forms, although it could be
> related.
>
> Dave
>
> [1] http://struts.apache.org/2.x/docs/freemarker-support.html
>
Re: Issue with Chinese Charctors
Posted by Dave Newton <da...@gmail.com>.
On Fri, Jun 29, 2012 at 6:35 AM, Sathish Kumar wrote:
> In our struts 2 project, we support Chinese language. While we save Chinese
> text in forms we see junk characters getting saved.
>
> While investigating, we found this link
>
> http://www.mkyong.com/struts2/struts-2-chinese-localization-issue/
>
> As per this,
>
> At the top of the JSP Page, we need to include
>
> *<%@ page contentType=”text/html;charset=UTF-8″ %>*
>
> Now the issue is, it is only possible with JSP pages. But in our case, we
> use free marker as our result type.
>
> What is the coresponding freemarker sysntax for the above JSP code?
>
Did you try setting the encoding in the `freemarker.properties` file as per
the freemarker support docs [1]?
This isn't necessarily what your issue is, though, if you're talking
specifically about *saving* I18N data from forms, although it could be
related.
Dave
[1] http://struts.apache.org/2.x/docs/freemarker-support.html