Search code examples
java.netunicodeencodingwindows-1252

Encoding from 1252 to Unicode .NET equivalent in java


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!


Solution

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