Encoding from 1252 to Unicode .NET equivalent in j

2019-09-14 15:59发布

I have the request to port a .NET web service to java. I need to find the equivalent java code for this piece of code written in .NET:

byte[] b = ... // Some file binary data.
byte[] encoded = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding(1252), System.Text.Encoding.Unicode, b);

Thanks in advance!

2条回答
Anthone
2楼-- · 2019-09-14 16:40

Have a look on the List of Supported Encoding in java. Cp1252 encoding in java is theequivalent encoding of windows 1252.

查看更多
Emotional °昔
3楼-- · 2019-09-14 16:43
byte[] b = ...
byte[] encoded = new String(b, "Cp1252").getBytes("UTF-16");
查看更多
登录 后发表回答