-2

Trying to print € symbol to screen using Unicode.

The following code displays OK in Eclipse but using the windows command line I get:

pound = ú
euro = Ç

Code:

class Test{      
public static void main(String[] args) {
       String euro = "\u20ac";
       String pound = "\u00a3";

        System.out.println("pound = " + pound);
        System.out.println("euro = " + euro);
    }
}

Why is this? Ctrl+alt+$ shows € command line so the symbol is there?

En-Motion
  • 899
  • 6
  • 21
  • 34
  • which platform? [Unicode characters in Windows command line - how?](http://stackoverflow.com/q/388490/995714), [How to Output Unicode Strings on the Windows Console](http://stackoverflow.com/q/3130979/995714), [Output unicode strings in Windows console app](http://stackoverflow.com/q/2492077/995714) – phuclv Jan 24 '16 at 16:09
  • http://illegalargumentexception.blogspot.com/2009/04/i18n-unicode-at-windows-command-prompt.html – phuclv Jan 24 '16 at 16:13
  • Thank you. chcp 1252 worked for me. – En-Motion Jan 24 '16 at 16:16
  • Possible duplicate of [What is character encoding and why should I bother with it](http://stackoverflow.com/questions/10611455/what-is-character-encoding-and-why-should-i-bother-with-it) – Raedwald Jan 24 '16 at 16:37
  • Related (but perhaps outdated?): [Java, Unicode, UTF-8, and Windows Command Prompt](http://stackoverflow.com/q/11927518/1468366) – MvG Jan 24 '16 at 16:44

2 Answers2

-1

Following worked for me:

  • Switch the console from the raster font to a Unicode TrueType font.

  • Type chcp 1252 to switch code page.

En-Motion
  • 899
  • 6
  • 21
  • 34
-1

Check the hexadecimal value for windows or linux or whatever operating system it's a little bit different here is for windows. Wikipedia

Castro Alhdo
  • 293
  • 3
  • 8