Hi all,

I'm having a compilation problem relating to some Chinese and Japanese characters that I have hardcoded into a hash table. When I compile this code inside an IDE like Eclipse or Netbeans I get no warnings, but when I do it outside of the IDE I get the following warning:

"unmappable character for encoding CP1252"

(From what I understand the default encoding for java is CP1252.)

What should I do about this? Would it be best just to compile with a UTF8 encoding tag as in ...

javac -encoding UTF-8 *.java

... or should I be using native2ascii in some way?

Any advice about the best approach here would be great. Thanks!

Recommended Answers

All 3 Replies

> ... or should I be using native2ascii in some way?

AFAIK, native2ascii is normally used when dealing with properties file since the specification says that properties file can contain only ASCII characters as mentioned here. IMO, instead of modifying the program text, you are better off setting the -encoding flag when compiling via command line.

BTW, are these locale sensitive strings part of the key or value part of the map? If used as keys, won't it be better to just use the ASCII characters. If used as values, would you be displaying them at any point in your application? In that case, you are better off placing them in a properties files.

> ... or should I be using native2ascii in some way?

AFAIK, native2ascii is normally used when dealing with properties file since the specification says that properties file can contain only ASCII characters as mentioned here. IMO, instead of modifying the program text, you are better off setting the -encoding flag when compiling via command line.

BTW, are these locale sensitive strings part of the key or value part of the map? If used as keys, won't it be better to just use the ASCII characters. If used as values, would you be displaying them at any point in your application? In that case, you are better off placing them in a properties files.

Yep, I'm hoping to display them in the application, so I'll do some more reading about properties files. Thanks for the advice, much appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.