aspose file tools*
The moose likes JSP and the fly likes Character encoding problem in properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Character encoding problem in properties file" Watch "Character encoding problem in properties file" New topic
Author

Character encoding problem in properties file

Sigrid Kajdan
Ranch Hand

Joined: Jan 14, 2007
Posts: 72
Hi,

I'm storing error messages in a properties file and - if necessary - display them in a jsp.
The jsp specifies an encoding of text/html, charset = UTF-8.
In my Eclipse workspace preferences, I specify an encoding of UTF-8 for text files.
Now, I have to use the � character in my properties file. Somehow, Eclipse wants me to use ISO-8859-1 for the properties file ("determined from content"), but if I accept that, it doesn't let me save the file after inserting the � character.
On the other hand, if I change the encoding to UTF-8, the browser will display garbage, even though the jsp is sent as UTF-8.
Things like using a "fresh" properties file or restarting eclipse don't work.

Anybody an idea?
Thank you,
Sigrid
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42928
    
  68
As part of the deployment, you should use the native2ascii tool to convert UTF-8 property files to ASCII. Then it should work fine. There's also an Ant task that can do this.

Note that the Properties class expects the files it opens to be in ISO-8859-1 (it's hardcoded), so it can't deal with UTF-8 encoded files.
Joan Horta Tosas
Ranch Hand

Joined: Feb 01, 2007
Posts: 59
I was reading that a minute ago. But if you only need the � symbol, you can use € instead. Is what I've always done for not having to do the conversion everytime I change something.
Sigrid Kajdan
Ranch Hand

Joined: Jan 14, 2007
Posts: 72
Thanks a lot for your help!
I will employ native2ascii in the future.

Just one little question to you, Joan, both your characters appear as � on the screen, so I'd like to ask what did you actually type in - a unicode code point starting with \u...?
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Viewing source it looks like euro flanked by & and ; without the spaces

& euro ;
Sigrid Kajdan
Ranch Hand

Joined: Jan 14, 2007
Posts: 72
Oh I see, thanks
Joan Horta Tosas
Ranch Hand

Joined: Feb 01, 2007
Posts: 59
Yes, sorry, I didn't look at the result on the page
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Character encoding problem in properties file