What are the enhancements in Internationalization in Java 9?


Internationalization enhancements in Java 9 include Unicode 8.0, UTF-8 properties files and enabling CLDR locale data by default. Java 9 supports up to Unicode 8.0 standards with 10,555 characters, 29 scripts, and 42 blocks.

In Java 9, the properties files are loaded in UTF-8 encoding. By default, reading an input stream throws MalformedInputException or UnmappableCharacterException. In this case, PropertyResourceBundle instance reset to a state before the exception, re-reads the input stream in ISO-8859-1, and continues reading.

If PropertyResourceBundle.encoding has set to either ISO-8859-1 or UTF-8, then PropertyResourceBundle instance read an input stream in that encoding, and throw an exception if encountering an invalid sequence. The system property read and evaluated when initializing the PropertyResourceBundle class, then any action that changes or removes the property has no effect.

If we specify ISO-8859-1:

  • Characters that can't be represented in ISO-8859-1 encoding must be represented by Unicode escapes.
  • Other encoding values have ignored this system's property.

If there is an issue, we can consider the below options:

  • Convert the properties file into UTF-8 encoding.
  • Specify the runtime system property.
java.util.PropertyResourceBundle.encoding=ISO-8859-1

Updated on: 06-Mar-2020

62 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements