java中GB2312字符串的判断(代码片段)

private boolean isGB2312(Stringstr) ... {
char[]chars=str.toCharArray();
booleanisGB2312=false;
for(inti=0;i<chars.length;i++)...{
byte[]bytes=(""+chars[i]).getBytes();
if(bytes.length==2)...{
int[]ints=newint[2];
ints[
0]=bytes[0]&0xff;
ints[
1]=bytes[1]&0xff;
if(ints[0]>=0x81&&ints[0]<=0xFE&&ints[1]>=0x40
&&ints[1]<=0xFE)...{
isGB2312
=true;
break;
}

}

}

returnisGB2312;
}

你可能感兴趣的:(java)