Java Utililty Methods UTF Convert

List of utility methods to do UTF Convert

  1. HOME
  2. Java
  3. U
  4. UTF Convert

Description

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

Method

String UTFToGB(String ostr)
UTF To GB
try {
 return ostr == null ? ostr : new String(ostr.getBytes("UTF-8"), "GB2312");
} catch (Exception e) {
 return ostr;
String utfToGBK(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:
...
String utfToString(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);

AltStyle によって変換されたページ (->オリジナル) /