1

Does anyone have any idea why money_format() is showing � instead of pound sign (£).

The function performs fine on my local server, but when I upload it to my remote server if renders incorrectly.

Does anyone know a solution?

MrWhite
  • 43,179
  • 8
  • 60
  • 84
dotty
  • 40,405
  • 66
  • 150
  • 195

2 Answers2

5

You need to use £, not £

A full list of characters affected in this way can be found at http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

  • 1
    you should be able to use the £ symbol if the encoding is correct (ie UTF-8), but +1 because `£` will work regardless of encoding. – Spudley May 19 '11 at 14:15
  • Yeah you're right. I always use £ though. At leat you'll know it'll work wherever you use it that way and it allows me to keep my coding consistent. –  May 19 '11 at 14:16
  • @dotty: entity-encode the output prior to sending it to the browser, either with `htmlentities()` or similar, or even just `str_replace()` or `strtr()`, etc. But I'd consider fixing your charset to UTF-8 as a higher priority. – Spudley May 19 '11 at 14:19
  • 6
    try `setlocale(LC_MONETARY, 'en_GB.UTF-8');` –  May 19 '11 at 14:19
  • setlocale(LC_MONETARY, 'en_GB.UTF-8'); Worked for me – dotty May 19 '11 at 14:30
  • Good stuff. Spudley's right, though, you should look at your page charset encoding to make sure it's correct. –  May 19 '11 at 14:32
  • 1
    `setlocale(LC_MONETARY, 'en_GB.UTF-8');` fixed it for me. Both my local and remote server were serving the content-type header `text/html; charset=UTF-8`. It wasn't a browser character issue, as the � symbol was also visible when viewing the output in a terminal window (with cURL) – Ade Jun 08 '16 at 14:01
0

Related: php remove/identify this symbol �

Quoted from Gumbo

The character � is the REPLACEMENT CHARACTER (U+FFFD). It is used when there was an error within an UTF code:

FFFD � REPLACEMENT CHARACTER

used to replace an incoming character whose value is unknown or unrepresentable in Unicode

Community
  • 1
  • 1
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383