Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1057

Issue when converting Windows-1252 characters to UTF-8 in Java [closed]

$
0
0

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


Viewing all articles
Browse latest Browse all 1057

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>