• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting odd currency symbol from convertNumber  RSS feed

 
Brian Saastad
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings (first post). I'm brand new to JSF and am converting a JSP application. I'm trying to do a simple currency conversion, but am getting an odd symbol in place of the '$'. My hex editor shows it as 0xc2 0xa4 at that position, but the c2 is invisible, so my currency amount looks like this:

ยค2,156,960.00

It's an English locale, and my other conversions look ok (percentages, etc) and the number formatting of my currency looks right, just the symbol is whacked. Here's the locale info from faces-config.xml:

<locale-config>
<default-locale>en</default-locale>
</locale-config>

and here's the code to display the currency. The getTotalSales() method just returns a Long:

<h:outputText value="#{sessionInfo.transMetrics['TOTAL'].totalSales}">
<f:convertNumber type="currency" />
</h:outputText>

If I explicitly set the value with currencySymbol="$" then it prints right, but of course I don't want to hard code that. The previous JSP version of this did what I expected. Has anyone seen this before? Am I missing something exceedingly simple and bone-headed? I've tried putting this in a page all by itself to make sure something else wasn't triggering this, but got the same result. Haven't been able to find anything doing web searches about this issue specifically.

This is JSF 2.0 running under Glassfish 3.1.2, developing on Windows XP in Eclipse Indigo. Any help would be greatly appreciated.

TIA,
--Brian
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Brian!

The circle-superimposed-on-an-X symbol is the Universal Currency Symbol (currency sign) and its character code is A4. I think that the "C2" part is a UTF-8 shifting indicator, but I'm not sure.

There's nothing wrong with your coding, so my suspicion is that you might have installed the wrong JDK and that it's defaulting to non-specific currency despite your locale-config.
 
Brian Saastad
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your definition of the Universal Currency Sign got me to thinking, could this be related to the fact that it somehow doesn't know that I'm dealing with US dollars instead of English pounds? After a little searching on that topic, I changed my locale specifier from 'en' to 'en_US' and, lo and behold, the '$' symbol showed up.

Here's the java version I'm using, which is just the one that came bundled with the Glassfish download:

$ ./java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode)

Thanks so much for the missing puzzle piece!
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point.

Just out of curiosity, what happens when you remove the default locale completely?
 
Brian Saastad
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting -- commenting out the locale-config section completely gets me a '$' symbol (at least under this browser.) But thinking further -- while this has been informative in terms of how the localization works -- I think I need to set the localeSymbol to '$' anyway because the actual AMOUNT is always in U.S. dollars, unless I change the bean accessor to convert it to local currency for display. Not sure that's relevant for this application, but something to think about anyway, if only for future reference.

Incidentally, the language settings in my browser (Firefox) are 'en-us', 'en' in order of preference. Should play with that as well and see how things behave ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!