File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes displaytag and japanese characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "displaytag and japanese characters" Watch "displaytag and japanese characters" New topic
Author

displaytag and japanese characters

praveen Shangunathan
Ranch Hand

Joined: Sep 06, 2005
Posts: 65
hi all,
i have some trouble with displaytag 1.1. hope you can help me with this. i am trying to display japanese characters in the footer like the number of pages, first, next etc., The page reads from a separate japanese property file(displaytag_ja.properties) but the display is gibberish. also the property file is utf-8, it contains actual japanese characters and not ascii.
is there a way i can manipulate how displaytag api reads from displatag.properties ?

for ex. one line in my japanese property file is
paging.banner.some_items_found=<span class="pagebanner">{0} {1} 日本found, displaying日本 {2} 日本to日本 {3}.</span>
but the page displayed is
205 items 日本found, displaying日本 1 日本to日本 25

please advice.
praveen
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

If this is a Java properties file and it's being read into a Properties object, then it must be encoded in ISO-8859-1, not UTF-8. Characters which can't be represented in ISO-8859-1 must be encoded using Unicode escapes; see the API documentation for Properties for the full story.
praveen Shangunathan
Ranch Hand

Joined: Sep 06, 2005
Posts: 65
paul,
This is not a java property file although I did have the same issue with java property file which i solved. the way i did is to have a wrapper around the getResouceBundle which returns a utf encoded resource bundle, so all is fine there.
But in this case im not sure how the displaytag api reads from the displaytag property file and the disaplaytag_ja.propeties file has to contain proper japanese characters and not unicode escapes.
thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

the way i did is to have a wrapper around the getResouceBundle which returns a utf encoded resource bundle

Don't you use native2ascii ?


[My Blog]
All roads lead to JavaRanch
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

praveen Shangunathan wrote:This is not a java property file
Since its name ends in ".properties", that suggests it is a properties file. How do you know it isn't one?
But in this case im not sure how the displaytag api reads from the displaytag property file
In other words, you don't actually know whether it's a properties file. My theory is that it is a properties file as far as the DisplayTag software is concerned.
the disaplaytag_ja.propeties file has to contain proper japanese characters and not unicode escapes.
Who says so? Especially when doing that seems to cause encoding problems? Try using native2ascii as Christophe suggests and see what happens. Or do an experiment where you replace one Japanese character with its equivalent Unicode escape and see if that fixes the problem for that character.
praveen Shangunathan
Ranch Hand

Joined: Sep 06, 2005
Posts: 65
@ Christophe and Paul
it is a requirement that properties be in japanese and NOT in unicode. therefore no native2ascii and no unicode escapes, although they will work !

The thing is I fixed a similar issue for property files read by our own codebase, because i know the api and was able to write wrappers. But with displaytag Im not sure which class to write a wrapper for or how the displaytag specific property files are read.

thank you
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

The page reads from a separate japanese property

Can you show us how you are using the displaytag ? And is the web page encoding set to utf-8 ?
praveen Shangunathan
Ranch Hand

Joined: Sep 06, 2005
Posts: 65
im using displaytag as below

<display:table name="aaa" uid="bbb" defaultsort="2" defaultorder="descending" requestURI="" pagesize="25">

</display>

In the mean time I fixed the issue by changing the displaytag.jar. I updated TableProperties.java file in the jar and this fixed the issue.

Thank guys for looking into this.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I updated TableProperties.java file in the jar and this fixed the issue.

You mean you that you changed a file from the displaytag library ? It doesn't sound a good idea. DisplayTag is supposed to support i18n. Check this.
praveen Shangunathan
Ranch Hand

Joined: Sep 06, 2005
Posts: 65
yes it is pretty bad
but for now this is how i got it to work.
and about displaytag already supporting i18n, it does. that is the reason the browser reads from japanese property file. the issue is specific only with displaying japanese characters properly. i do have chracterencoding set to utf8 and all other non-displaytag renders properly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: displaytag and japanese characters