开发者

Missing currency symbols on linux server

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 symbol开发者_StackOverflow社区s 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.


I'm guessing that the issue is probably related to the way you're actually formatting the number or locale rather than the font. Check out the Grails reference on formatting numbers as currency and the java.util.Currency API doc for more information. A quick way to rule out a font related issue is just to type (copy&paste if necessary) the symbol you're after into a GSP and verify that you can view it in your browser:

  • $
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜