// 全角转半角的 转换函数
public static final String full2HalfChange(String fullStr)
throws UnsupportedEncodingException {
if (isNULLString(fullStr)) {
return fullStr;
}
fullStr = stringToUnicode(fullStr);
fullStr = unicodeToString(fullStr);
StringBuffer outStrBuf = new StringBuffer("");
String Tstr = "";
byte[] b = null;
for (int i = 0; i < fullStr.length(); i++) {
Tstr = fullStr.substring(i, i + 1);
// 全角空格转换成半角空格
if (Tstr.equals(" ")) {
outStrBuf.append(" ");
continue;
}
b = Tstr.getBytes("unicode");
// 得到 unicode 字节数据
if (b[2] == -1) {
// 表示全角?
b[3] = (byte) (b[3] + 32);
b[2] = 0;
outStrBuf.append(new String(b, "unicode"));
} else {
outStrBuf.append(Tstr);
}
}
return outStrBuf.toString();
}