我已经尝试将字节转换cp1252
为字节,utf8
但一切都是徒劳的。
例如:我有byte[] 0xB5(cp1252)
并且我想转换为byte[] 0xC3, 0xA0(utf8)
.
我想要这样:μ --> à。
我的代码,但它不工作:
public void convert(){
try {
byte[] cp1252 = new byte[]{(byte) 0xB5};
byte[] utf8= new String(cp1252, "CP-1252").getBytes("UTF-8");
// values of utf8 array are 0xC2, 0xB5 not 0xC3, 0XA0 as I expected
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}