第1个回答 推荐于2018-05-04
public static int getAscii(char cn){
byte[] bytes = (String.valueOf(cn)).getBytes();
if(bytes.length == 1){ //单字节字符
return bytes[0];
}else if(bytes.length == 2){ //双字节字符
int hightByte = 256 + bytes[0];
int lowByte = 256 + bytes[1];
int ascii = (256 * hightByte + lowByte) - 256 * 256;
return ascii;
}else{
return 0; //错误
}
}本回答被网友采纳