parsing of a formatted currency string

  • Thread starter Thread starter shriop
  • Start date Start date
S

shriop

I'm looking for a nifty way of parsing a numeric value back out of a
previously formatted currency string. Even if it's long winded
involving grabbing symbols from the current locale. I'm trying to build
some functionality for other developers to be able to read in data from
flat files, and I don't want to force my logic to be only US specific.
I was hoping to make it as open as possible to handle whatever kind of
formats they've created. Any help would be appreciated.

Bruce
 
I'm looking for a nifty way of parsing a numeric value back out of a
previously formatted currency string. Even if it's long winded
involving grabbing symbols from the current locale. I'm trying to build
some functionality for other developers to be able to read in data from
flat files, and I don't want to force my logic to be only US specific.
I was hoping to make it as open as possible to handle whatever kind of
formats they've created. Any help would be appreciated.

This is one of the trickiest things.

Because what most routines/libraries assume is that the currency and currency
format are tied directly to the locales.
According to this, if the locale is French/France, then "1 234 567,89 €"
And if the locale is English/U.S.A., then "$1,234,567.89"

But currency is not tied to a locale. Only currency format is.
So you can have e price in dollars formated in a French/France locale:
"1 234 567,89 dollar des États-Unis"

There are many other traps here. For instance $ is used as currency symbol in
many other countries, some not even named dolar (ie the Mexican Peso).
 
Back
Top