| international currency presentation format |
| by mrgym on 2004/9/26 1:51:44 (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); |