Java.util.Properties and Cp1250

Is it possible to use java.util.Properties with encoding different from the standard?

+3
source share
3 answers

Not if you

  • java 6 or later works
  • manages the code that loads the properties file, and can use Reader. See javadoc .

This is a rather annoying spec error. There are several workarounds, perhaps the easiest one is to automatically create a unicode compatible file with the appropriate code (cp1250, utf-8, whatever).

Java comes with a native2ascii transcoder to do this for you:

RFE :

+3

, , load() store(), Reader/Writer InputStreamReader/OutputStreamWriter .

, .

: Java 1.6 - , dsadinoff.

+5

, ant script native2ascii:

<property name="javac.source.encoding" value="Cp1250"/>

<native2ascii src="${src.dir}" dest="${classes.dir}"
   encoding="${javac.source.encoding}"
   includes="**/*.properties"/>
+1

Source: https://habr.com/ru/post/1716574/


All Articles