Java Internationalization and Localization
Pages: 1, 2, 3, 4, 5
Demo Applet
An applet was created as shown in Figure 4, with the following applet parameters.
- File -- the text file to be displayed in applet.
- Encoding -- the encoding to be used during reading of the text file
- Country -- the upper-case two-letter codes as defined by ISO-3166
- Lang -- the lower-case two-letter codes as defined by ISO-639
- FontName -- the preferred font name to be used in displaying the text by default
- FontSize -- the preferred font size by default
The applet reads the file with the specified encoding, then displays
the text using the preferred font name and size. The
country and lang parameters are used to create the
java.util.Locale object. The text is displayed using
java.awt.Canvas. Line wrapping is performed using
java.text.BreakIterator.
Some Observations
What follows are some observations when the demo applet is executed on IE, Navigator 4.76, and 6 for Chinese, Japanese, and Korean text.
Encoding in IE
IE does not support every encoding
supported in the JDK. For example, if you try reading a native Korean
character in our test applet you will encounter the following:
Related Reading:![]() Java Internationalization |
|||||
UnsupportedEncodingException
In order to display Korean characters correctly in all browsers, we need to do some preprocessing. We need to perform transcoding, where the Korean text file is transformed from one encoding to another; in this case, EUC-KR to UTF8. Transcoding can be implemented easily in Java. We read in the data in one encoding and write out the data in another encoding.
After transcoding the Korean text files to UTF8, we specify the encoding parameter in the applet as UTF8. Then use the preferred font name "Batang" to display Korean characters in the applet.
|
IE Java VM
If the Font object is not created with
FontX class but, rather, with
new Font("system font name")
then our Korean characters will be displayed as follows on IE Java VM, using the "Batang" and "Dialog" font names.
|
|
Netscape Navigator 6 JDK 1.3
Navigator 6 with Sun JDK
1.3 VM works well, except for updated fonts with only a change of font
style.
For example, if the current Font setting in the applet is
Font name = 'Batang'
Font size = 14
Italic = No
Bold = No
and we want to have the same font name, size, but with italic rather than bold, then if we just check the Italic checkbox, and depress the 'Update' button, it will not work.
Instead, we need to set Font Size to any value other than 14 (the current value), and set Italic to "Yes". Then depress the "Update" button. Then set Font Size back to 14. Depress the "Update" button again. You can then get what you wanted as follows:
Font name = 'Batang'
Size = 14
Italic = Yes
Bold = No
On IE and Navigator 4.76 (assuming the necessary changes to
font.properties.en), we do not have this problem.
When we run the Korean character demo in Navigator 6, the loading of the applet took much longer to load than with IE. It may be due to the size of this TrueType Font (15157KB) (see Figure 2). Another reason is likely due to IE being integrated with the OS.



