re:Java and UTF

From: Erik Kovach (Erik.Kovach@mailhost.bellhow.com)
Date: Wed Jul 02 1997 - 14:03:32 EDT


Java has the power to manipulate the bytes between dozens of encodings
quite easily (although it took myself and several colleagues a while).
Try this nifty function. It says "read these bytes as encoding
<inEnc> and output the bytes in encoding <outEnc>." Encodings can be
Big5, UTF-8 (the standard one...not the goofy Java one), MacThai, or
whatever is supported by the JDK.

For a list of supported encodings that can be specified for the inEnc
and outEnc paramaters, see:

http://java.sun.com:80/products/jdk/1.1/intl/html/intlspec.doc7.html#20888

For more information on the getBytes function and the String constructor,
check out:

http://java.sun.com/products/jdk/1.1/docs/api/java.lang.String.html#getBytes(java.lang.String)
http://java.sun.com/products/jdk/1.1/docs/api/java.lang.String.html#_top_

[BEGIN FUNCTION]

public static byte [] convert(byte [] inBytes, String inEnc, String outEnc)
    throws UnsupportedEncodingException
{
    return new String(inBytes, inEnc).getBytes(outEnc);
}

[END FUNCTION]



This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:20:35 EDT