How to print CMD special characters when formatting currencies?

0

A few days ago I did an exercise to format currencies and I used the following code for this:

String us, china, france;
us = NumberFormat.getCurrencyInstance(Locale.US).format(payment);
china = NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment);
france = NumberFormat.getCurrencyInstance(Locale.FRANCE).format(payment);

At the command prompt should look something like this:

US: $12,324.13
China: ¥12,324.13
France: 12 324,13 €

But something went like this:

US: $12,324.13
China: ?12,324.13
France: 12▒324,13 ▒

I know the code is correct because it worked, but it does not display correctly. How do I make sure that whenever I need to run special characters through the CMD they display correctly?

    
asked by anonymous 22.08.2018 / 03:11

1 answer

1

The most reliable would be to use the GUI. Minimum example:

JOptionPane.showMessageDialog(null, new String[] {us, china, france});

No CMD will not be able to display all symbols correctly because it basically does not support Unicode. With

> CHCP 1252

will be able to show (Euro) but probably not (\ uFFE5, Yen). Maybe this page about CHCP help more ...

In English Stackoverflow you have this question with some answers which can help.

    
22.08.2018 / 14:51