Why some older web browsers (not all) incorrectly display currency symbols when symbols are produced by php NumberFormatter() but display correct symbol when given as html entity. Since correct symbol is displayed via HTML entity code it means that browser has the font to display the currency symbol correctly. For example SRWare Iron v.49 behaves like this.

NOTE: I used an asterisk at front of the price below (*90,023) but the browsers in question actually display a little square in place of currency symbol.

$locale = 'ja-JP'; $currency = 'JPY'; $formatter = new NumberFormatter($locale."@currency=$currency", NumberFormatter::CURRENCY); header("Content-Type: text/html; charset=UTF-8;"); print htmlspecialchars($formatter->formatCurrency('90023.12', $currency)); Output: *90,023 //Incorrect output, should be ¥90,023 print '¥'; //HTML entity for Japanese Yen Output: ¥ //Correct currency symbol when given as html entity

Olivier's user avatar

Olivier

19.7k1 gold badge12 silver badges34 bronze badges

Jimski's user avatar

12

There are actually two Yen characters defined in Unicode:

YEN SIGN (U+00A5) FULLWIDTH YEN SIGN (U+FFE5)

NumberFormatter uses the second one, as shown by this test:

$locale = 'ja-JP'; $currency = 'JPY'; $formatter = new NumberFormatter($locale."@currency=$currency", NumberFormatter::CURRENCY); $s1 = $formatter->formatCurrency(1, $currency); $s2 = "\u{FFE5}1"; var_dump($s1 == $s2);

Outputs true (demo).

If no font with that character is available, then it will not show correctly (unless the browser is smart enough to substitute it with the usual Yen character).

Olivier's user avatar

2 Comments

Tested and confirmed. This was exactly the problem.

2025-11-25T19:57:39.11Z+00:00

I believe that is actually the OS problem (not the browser problem) : In Win 11 box everything is ok (even using SRWare Iron v.49 browser). But interestingly the OP has never indicated what OS he is using .

2025-11-27T05:49:28.883Z+00:00

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.