Java Utililty Methods UTF Convert

List of utility methods to do UTF Convert

Description

The list of methods to do UTF Convert are organized into topic(s).

Method

StringUTFToGB(String ostr)
UTF To GB
try {
    return ostr == null ? ostr : new String(ostr.getBytes("UTF-8"), "GB2312");
} catch (Exception e) {
    return ostr;
StringutfToGBK(byte[] srcByte)
utf To GBK
StringBuffer str = new StringBuffer();
int len = srcByte.length;
int char1, char2, char3;
int count = 0;
while (count < len) {
    char1 = srcByte[count] & 0xff;
    switch (char1 >> 4) {
    case 0:
...
StringutfToString(byte[] src, int srcIndex, int len)
Return bytes in Utf8 representation as a string.
char dst[] = new char[len];
int len1 = utfToChars(src, srcIndex, dst, 0, len);
return new String(dst, 0, len1);