1

Is there any mapping table between windows code and java charset?

Java Charset list

Windows Code page list

Why I want that: I have to read and analyse a binary file which contains part:

0x00 word codepage like 1252, 936, 65001 I knew, and also 50222 I did not know.
0x02 word string length
0x04 bytes null-terminated string 
...more strings...

I wrote the code:

int codepage = read16(inputStream);
int length = read16(inputStream);
byte[] bytes = new byte[length];
inputStream.read(bytes, 0, length);
String str = new String(bytes, getCharsetFromCodepage(codepage));

and getCharsetFromCodepage is what I want.

viruscamp
  • 39
  • 3
  • 1
    There is similar thing in javascript https://github.com/czhj/codepage-encoding/blob/master/codepages.json – viruscamp Sep 05 '17 at 06:07
  • Just from looking at the list, it looks like converting the canonical `java.nio` name to lower case will give you the .net name. – Dawood ibn Kareem Sep 05 '17 at 06:20
  • Can't you map the code pages on a string, using "identifiers" is not a really portable way to talk between different languages – Ferrybig Sep 05 '17 at 06:47
  • Default code page of locale https://msdn.microsoft.com/en-us/library/aa912040.aspx – viruscamp Sep 05 '17 at 08:04

0 Answers0