Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
dawolfen
Posts: 16
Registered: ‎03-16-2011
My Device: Bold 9000
My Carrier: Rogers

CurrencyFormatter.format returns NaN for non-en_US locales

I recently received feedback from some users of my program that NaN shows up where all the numbers should be. My data comes from a webservice that returns xml formatted to en_US. I then parse the data and construct HTML which is shown in the QNXWebStageView. Things work great when the device is set to en_US, but if someone has their settings to something like fr_FR, this is where the trouble begins.

 

I can't even get simple code such as this to work:

 

var frCurrencyFormatter:CurrencyFormatter = new CurrencyFormatter("fr_FR");

var value:smileyfrustrated:tring = frCurrencyFormatter.format(7);

trace(value);

 

This ends up printing NaN as opposed to 7.

 

Note: this works fine when the simulator is set to US English, but returns NaN when set to a different culture such as fr_FR.

 

As a .Net developer, this really frustrates me coming to a language like this where things I take for granted never seem to work without a few headaches.

 

Any help would be greatly appreciated!

 

thanks,

 

David

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: CurrencyFormatter.format returns NaN for non-en_US locales

Try "fr" or "FR". You will find that AS3 does make a lot of things very easy to do. Hope this is just an initial speed bump.
Please use plain text.
Contributor
dawolfen
Posts: 16
Registered: ‎03-16-2011
My Device: Bold 9000
My Carrier: Rogers

Re: CurrencyFormatter.format returns NaN for non-en_US locales

Unfortunately neither "fr", "FR", "fr_FR" nor "fr-FR" work.

 

Doesn't look like the NumberFormatter works either.

 

Curiously, the reverse function works: parseNumber works as expected.

 

I guess for the time being I'll release a version which will convert any NaN numbers and use toString() instead, so my international users will have to suffer with values like 7 instead of 7.00.

 

I suppose later with some time I'll write my own version of format which works correctly, wish I didn't have to do all this though.

 

Thanks for the help

 

If anyone else has run into anything similar to this and has a solution, I'm open to ideas.

 

cheers

 

-David

Please use plain text.