Internationalization and localization tools

Locale-Sensitive Java Method


public OutputStream getLocalizedOutputStream(OutputStream out)

Internationalization (I18n) Method Overview

Creates what Sun's deprecated Javadocs refer to as a localized version of an input stream. This method takes an OutputStream and returns an OutputStream equivalent to the argument in all respects except that as Unicode characters are written to the stream, they are automatically converted to the local character set.

I18n Issues

Internationalization problems arise through use of this method when the local (machine) character encoding is not the desired character encoding. Further, it is a recommended I18n practice to always use a Unicode character encoding to ensure that the output encoding can properly represent any characters that the program might attempt to write. Use of the default encoding does not ensure support of characters from any locale.

Suggested Replacement
public OutputStreamWriter(OutputStream out,
    String charsetName)
   throws UnsupportedEncodingException

Instead of:

OutputStream original;
//Instantiate the output stream here by
//opening an output stream on a file, etc. ...
Runtime rt = Runtime.getRuntime();
OutputStream new = rt.getLocalizedOutputStream(in);


OutputStream out;
//instantiate the OutputStream here ...
OutputStreamWriter writer = new OutputStreamWriter(
   out, getUnicodeCharacterEncoding());

Locale-Sensitive Java Methods


Lingoport internationalization and localization services and software