Home > OS >  Eclipse STS console fails to display some UTF-8 chars
Eclipse STS console fails to display some UTF-8 chars

Time:04-05

I am using Spring Tool Suite v4.13.1, a customisation of Eclipse 3.18.

I have the following code:

NumberFormat fChina = NumberFormat.getCurrencyInstance(Locale.SIMPLIFIED_CHINESE);
NumberFormat fFrance = NumberFormat.getCurrencyInstance(Locale.FRENCH);
System.out.println("French: "   fFrance.format(123456.78));
System.out.println("China:  "   fChina.format(123456.78));

And the output I see on the console is:

French: 123 456,78 ¤
China: ¥123,456.78

So, the Chinese currency character appears correctly but the € symbol does not.

In trying to solve this I have included UTF-8 encoding in the run configuration like so:

java -Dfile.encoding=UTF-8 -classpath /home/.../target com.example.Currencies

I have also changed the font used by the Terminal to FreeMono Regular but that did not make any difference.

I have read many postings related to UTF-8 but given that I can see the correct Chinese currency char, I think that might not be the right path. Yet, I am at a loss as to why this widely used character would not display correctly.

CodePudding user response:

¤ is Unicode U 00A4 - Currency Symbol.

The locale for France should be Locale.FRANCE, not Locale.FRENCH.

Locale.FRENCH covers anywhere that speaks French so the generic currency symbol is used. Locale.FRANCE will give you the Euro.

  • Related