I'm decoding some data which is partially encoded in Windows-1252, and when I try to convert the char code 148 decimal (94 hex) into UTF-8, I get a nonsense result. The code I'm using is below:
String character = new String(new byte[]{(byte) 148}, "Windows-1252");character = new String(character.getBytes(StandardCharsets.UTF_8));System.out.println(character);
When I run this snippet, I get �?
instead of the expected character ”
. The decoded bytes are [226, 128, 63]
. This code works for literally every other character I've needed it for (everything from 128 to 159).
The JDK I'm using is Temurin 17.0.6