java 怎么知道字符串的编码
只能逐一判断
String iso8859 = new String(sb.toString().getBytes('iso8859-1'));
String gbk = new String(sb.toString().getBytes('gbk'));
String utf8 = new String(sb.toString().getBytes('utf-8'));
if(iso8859.equals(sb.toString())){
System.out.println('iso8859');
}else if(gbk.equals(sb.toString())){
System.out.println('gbk');
}else if(utf8.equals(sb.toString())){
System.out.println('utf8');
}
赞0
踩0