Problem with PropertyResourceBundle and unicode

K

kiran

Hi,
I am trying to read some russian characters from my .properties file
(encoded in ISO-8859-1) using a PropertyResourceBundle. The russian
characters are entered in the .properties file in unicode. My problem
is that the method call PropertyResourceBundle.getString(key) returns
valid russian charcters for some unicode charactes and square boxes for
some.
For example:
if key=\u0410\u0424\u0426, valid russian characters are returned
but if key=\u0460\u04C1\u0482, it returns square boxes.

All the above unicode characters are derived from
http://www.unicode.org/charts/PDF/U0400.pdf.

I am not sure what is special about the second string. Is it that java
has limitations on a set of characters or do I need to do anything
special to my JDK or WinXP.

Thanks in advance for the help.

-Kiran
 
T

Thomas Weidenfeller

kiran said:
For example:
if key=\u0410\u0424\u0426, valid russian characters are returned
but if key=\u0460\u04C1\u0482, it returns square boxes.

You are mixing up glyphs (roughly: how a character is painted) and code
points (roughly: which number a character has).
PropertyResourceBundle.getString(key) for sure does not return "square
boxes". It doesn't care about any visual representation, it just returns
a sequence of numbers which is supposed to represent a sequence of
characters (string) in Unicode code points.

So the first thing to check would be if the returned string indeed
contains the numbers you expect. Use a debugger or a small loop to print
the numbers (char codes), instead of the characters.
I am not sure what is special about the second string. Is it that java
has limitations on a set of characters or do I need to do anything
special to my JDK or WinXP.

If the numbers in the string are correct, then you have an issue with
your font. The font you use simply doesn't contain any glyphs for the
characters you asked for. You might want to check this outside of java
with some platform specific font viewer or tool.

For details how Java handles fonts see

http://java.sun.com/j2se/1.5.0/docs/guide/intl/font.html

Note, the mechanism has changed slightly over time, so you better look
up the version of the document which matches your Java version, if you
don't use 1.5.

/Thomas
 
H

hiwa

kiran said:
Hi,
I am trying to read some russian characters from my .properties file
(encoded in ISO-8859-1) using a PropertyResourceBundle. The russian
characters are entered in the .properties file in unicode. My problem
is that the method call PropertyResourceBundle.getString(key) returns
valid russian charcters for some unicode charactes and square boxes for
some.
For example:
if key=\u0410\u0424\u0426, valid russian characters are returned
but if key=\u0460\u04C1\u0482, it returns square boxes.

All the above unicode characters are derived from
http://www.unicode.org/charts/PDF/U0400.pdf.

I am not sure what is special about the second string. Is it that java
has limitations on a set of characters or do I need to do anything
special to my JDK or WinXP.

Thanks in advance for the help.

-Kiran

Font issue on your platform?
Try different platform.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,216
Messages
2,571,116
Members
47,720
Latest member
mohdkaif002

Latest Threads

Top