1
mrgym
international currency presentation format
  • 2004/9/26 1:51

  • mrgym

  • Just popping in

  • Posts: 28

  • Since: 2002/4/26


(I hope this is the correct forum for this question)

I'm trying to write a module that has an admin preference for currency format. Each country has many differences in currency PRESENTATION format:

- symbol may be before or after the digits
- group separator characters differ

Examples;
en_US $1,000,000
fr_FR 1 000 000€

What approach should I take if I want to offer different currency presentation formats? ( I don't need to worry about the fractional portion of the currency for my app)

How about setlocale() and money_format()?

//'en_US','en_GB','fr_FR'are example prefs from {prefix}_config

setlocale(LC_MONETARY, 'en_US');
print("before:$x<br>");
$y = money_format("%.0n",$x);
print("after:$y<br>");

Or, should I set prefs for the symbol, symbol position, and group separator and write my own functions?

Another note. setlocale and money_format give a two-byte utf8 currency sign which does NOT display well as HTML 4. To convert to ASCII from the utf8, you may have to:

$localeArray = localconv();
$symbol = $localeArray['currency_symbol']; //what is symbol?
$symbolReplacement = utf8_decode($symbol);

//the new string with single-byte currency symbol
$y = preg_replace("/$symbol/",$symbolReplacement,$y);



Login

Who's Online

234 user(s) are online (167 user(s) are browsing Support Forums)


Members: 0


Guests: 234


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits