National letters in strings from ResourceBundle

B

Brzezi

Hi.

I`m writing program, in it I`m using strings received from .properties file
by ResourceBoundle, end if I put this strings into components like JLabel,
JButton, instead of national letters (in this case Polish letters) I see
'?'

I use NetBeans4.0 IDE, if I hardcode strings into source, everything is
good, without i'?', .properties files I edit in NetBeans too,

Do you have any idea how to solve it?


Pozdrawiam
Brzezi
 
O

Oscar kind

Brzezi said:
I`m writing program, in it I`m using strings received from .properties file
by ResourceBoundle, end if I put this strings into components like JLabel,
JButton, instead of national letters (in this case Polish letters) I see
'?'

This looks like character encoding problem.

ResourceBundle is an abstract class, with two known subclasses. For a
resource bundle read from a .properties file, PropertiesResourceBunble is
used. The API for this class refers to ResourceBundle and Properties. It
also makes a special note of mentioning charcater encodings at:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#encoding

A quote from that page:
"This format uses the ISO 8859-1 character encoding. Characters that cannot
be directly represented in this encoding can be written using Unicode
escapes; only a single 'u' character is allowed in an escape sequence.
The native2ascii tool can be used to convert property files to and from
other character encodings."

For more information on unicode escapes, see:
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#100850
 
T

Thomas Weidenfeller

Brzezi said:
Hi.

I`m writing program, in it I`m using strings received from .properties file
by ResourceBoundle, end if I put this strings into components like JLabel,
JButton, instead of national letters (in this case Polish letters) I see
'?'

(a) Only use ISO Latin 1 characters in the properties files
(b) For other characters use the \u.... notation
(c) To avoid having to type all the \u stuff manually, use the
native2ascii tool that comes with the SDK and add it to your build system.

/Thomas
 

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
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top