PHP: Multi-byte-safe number_format function
I recently ran into a problem with PHP’s built-in number_format function. The function is actually quite handy: It allows you to format a number in a manner that is appropriate for the language your website is currently in.
Example: To write the number 4505 and 31 hundredths in English, you’d write “4,505.31″. In German or Spanish however, the comma is the decimal separator, in turn using the point as the “digit group separator”: “4.505,31″. Swiss German, however, uses an apostrophe-like character as a digit group separator: “4′505,31″. And so on, and so forth.
All of these are supposedly addressed by using the number_format() function, feeding it the number to be displayed and the regionally appropriate separator characters.
Sadly though, when you do this for Russian and other eastern European languages, your result looks like this: Read the rest of this entry »
My take-off to Pittsburgh is coming closer and closer, and in the meantime, my to-do list seems to be getting longer and longer, but I am bravely fighting through it :).