I have a java application that needs to display currency symbols. I’m running on a Linux(Ubuntu) server.
On Linux server LANG=en_GB.UTF-8
The following code tests the problem:
import java.util.Currency;
import java.util.Locale;
import java.text.NumberFormat;
public class SymbolTest
{
public static void main(String[] args)
{
System.out.println("Hardcoded Unicode Currency Symbol for GBP [\u00A3] ");
System.out.println("Currency Symbol for GBP with Locale [" + Currency.getInstance(Locale.UK).getSymbol() + "]");
System.out.println("Currency Symbol for US with Locale [" + Currency.getInstance(Locale.US).getSymbol() + "]");
System.out.println("Currency Symbol for FRANCE with Locale [" + Currency.getInstance(Locale.FRANCE).getSymbol() + "]");
}
}
gives the output:
Hardcoded Unicode Currency Symbol for GBP £
Currency Symbol for GBP with Locale [£]
Currency Symbol for US with Locale [USD]
Currency Symbol for FRANCE with Locale [â¬]
I suspect this is a Locale or Lang problem on the Ubuntu server.
What should I install/configure on the linux server to enable the currency symbols to display?
Your program is correctly trying to output UTF-8, but your terminal apparently doesn’t know that it’s supposed to be in UTF-8 mode. So your terminal is at fault here. What terminal are you using?
Try redirecting the output of the program to a file and open that file with a UTF-8 capable editor to verify that the output is correct.