Java Utililty Methods String to Chinese GB2312

List of utility methods to do String to Chinese GB2312

Description

The list of methods to do String to Chinese GB2312 are organized into topic(s).

Method

booleanisGB2312(char c)
is GB
Character ch = new Character(c);
String sCh = ch.toString();
try {
    byte[] bb = sCh.getBytes("gb2312");
    if (bb.length > 1) {
        return true;
} catch (java.io.UnsupportedEncodingException ex) {
...
StringtoGB2312(String s)
to GB
if (s == null || s.length() < 1)
    return s;
byte[] temp_b = s.getBytes("ISO-8859-1");
String sTmpStr = new String(temp_b, "GB2312");
return sTmpStr;
StringtoGB2312(String s)
Encode the string to GB2312
if (s != null && s.length() > 0) {
    byte[] byteTmp = s.getBytes("ISO8859_1");
    s = new String(byteTmp, "GB2312");
return s;
StringtoGb2312(String str)
to Gb
try {
    return new String(str.getBytes("ISO8859_1"), "GB2312");
} catch (Exception e) {
    return str;