protected byte[] shortToByteArrayThreeUtf8(short unishort) {
int temp = unishort;
byte[] b = new byte[3]; b[2] = (byte) (new Integer(temp & 0x3f).byteValue() | 0x80);
temp = temp >> 6;
b[1] = (byte) (new Integer(temp & 0x3f).byteValue() | 0x80);
temp = temp >> 6;
b[0] = (byte) (new Integer(temp & 0x03).byteValue() | 0xe0); return b;
}请问这段代码转换问题在哪里?
最后得到的UTF-8码码值应该有问题
try {
newstr = new String(jisUtf8bytearray, "UTF-8");//UTF-8编码转为字符
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
但是却可以取到正确的字符,是什么道理?
int temp = unishort;
byte[] b = new byte[3]; b[2] = (byte) (new Integer(temp & 0x3f).byteValue() | 0x80);
temp = temp >> 6;
b[1] = (byte) (new Integer(temp & 0x3f).byteValue() | 0x80);
temp = temp >> 6;
b[0] = (byte) (new Integer(temp & 0x03).byteValue() | 0xe0); return b;
}请问这段代码转换问题在哪里?
最后得到的UTF-8码码值应该有问题
try {
newstr = new String(jisUtf8bytearray, "UTF-8");//UTF-8编码转为字符
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
但是却可以取到正确的字符,是什么道理?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货