为了计算字符在码表里的码值肯定要通过反码计算原码,自己琢磨了一个方法,记录下
byte[] b = "卷".getBytes(Charset.forName("GBK"));
short n = 0;
short tmp = 0;
for (byte c : b) {
if (c < 0) {
tmp = (short) (Math.abs(c) - 1 + 0x80);
n = (short) ((n << 8) + (tmp ^ 0x7F));
} else {
n = (short) ((n << 8) + c);
}
}
return n;