I'm attempting to print a deck of cards to system.out, with the suits represented by ♥, ♦, ♣, and ♠. I've copy-pasted the characters into my code:
deck.offer(new Card(v, (i == 0) ? "\u2666" : (i == 1) ? "♦" : (i == 2) ? "♣" : "♠"));
As you can see, I've tried escaping the symbols and directly pasting them into my code. Eclipse (the IDE that I use) gave me the option to change the encoding of the .java file to UTF-8, but my System.out.print()'s still show '?' as the symbols.
How do I print ♥, ♦, ♣, and ♠ to the terminal?
EDIT: Oleski answered my question below. Thank you!
It's possible that the terminal you're viewing the characters in is not interpreting them as UTF-8. That is, the characters are encoded in UTF-8 correctly, but the terminal is not set to interpret them as UTF-8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With