Encoding from 1252 to Unicode .NET equivalent in java

孤街醉人 提交于 2019-12-25 08:11:27

问题


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!


回答1:


byte[] b = ...
byte[] encoded = new String(b, "Cp1252").getBytes("UTF-16");



回答2:


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



来源:https://stackoverflow.com/questions/8521788/encoding-from-1252-to-unicode-net-equivalent-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!