I'm attempting to output a UTF-8 full block character (aka U+2588
) with a PrintStream
. The characters which are output are for the individual bytes which make up this code point. Thus I get e2 96 88
as â–ˆ
.
I initialize the PrintStream
object for UTF-8 and print a single full block character with the PrintStream.println(String)
method:
PrintStream ps = new PrintStream(System.out,
true,
"UTF-8");
ps.println("\u2588");
(This prints the characters which I showed above.)
This page shows the full block character's Unicode offset, as well as the individual hexadecimal bytes that make up the character. Looking up each of these bytes (which I did here, here, and here) gives the characters which are shown above. Why is each of these bytes being interpreted as a separate character by the PrintStream
?
EDIT: This was run against both JDK 1.8.0 update 131 & JDK 11.0.1 on Windows 10 Education 64 bit. I have tested this in Eclipse and through the Command Line. I did not use any compilation flags.