Unicode Programming
in Java
In the Java programming language char values represent Unicode characters.
If you want to convert other non-Unicode text to Unicode, or Unicode
text to non-Unicode, you need to do some work. Here is the sample
code:
When you create InputStreamReader and OutputStreamWriter objects,
you need to specify the byte encoding that you want to convert.
For example, to translate a text file in the UTF-8 encoding into
Unicode, you create an InputStreamReader as follows:
If you omit the encoding identifier, InputStreamReader and OutputStreamWriter rely on the default encoding. You can determine which encoding an InputStreamReader or OutputStreamWriter uses by invoking the getEncoding method, as follows:
|