[javascript] Why can't I display a pound (£) symbol in HTML?

I'm trying to display the pound symbol in HTML (from PHP) but all I get is a symbol with a question mark.

The following are things that I've tried.

In PHP:

header('Content-type: text/html; charset=utf-8');

In HTML, put this in the head tag:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

I tried displaying it using a javascript function which converts it to:

&amp;#65533;

I suppose it would help if I knew what I was doing... but I guess that's why I'm asking this question :)

This question is related to javascript html

The answer is


1st: the pound symbol is a "special" char in utf8 encoding (try saving £$ in a iso-8859-1 (or iso-8859-15) file and you will get ä when encoding using header)

2nd: change your encoding to utf8 form the file. there are plenty of methods to do it. notepad and notepad++ are great sugestions.

3rd: use ob_start(); (in php) BEFORE YOU MAKE ANY OUTPUT if you are getting weird encoding errors, like missing the encoding sometimes. and YES, this solves it! this kind of errors occurs when a page is encoded in windows-1252(ANSI),ASCII,iso-8859-1(5) and then you have all the others in utf8. this is a terrible error and can cause weird things like session_start(); not working.

4th: other php solutions:

utf8_encode('£');
htmlentities('£');
echo '&amp;pound;';

5th: javascript solutions:

document.getElementById('id_goes_here').innerText.replace('£','&amp;pound;');
document.getElementById('id_goes_here').innerText.replace('£',"\u00A3");
$(this).html().replace('£','&amp;pound;'); //jquery
$(this).html().replace('£',"\u00A3"); //jquery
String.fromCharCode('163');

you MUST send £, so it will repair the broken encoded code point. please, avoid these solutions! use php! these solutions only show how to 'fix' the error, and the last one only to create the well-encoded char.


You could try using &pound; or &#163; instead of embedding the character directly; if you embed it directly, you're more likely to run into encoding issues in which your editor saves the file is ISO-8859-1 but it's interpreted as UTF-8, or vice versa.

If you want to embed it (or other Unicode characters) directly, make sure you actually save your file as UTF-8, and set the encoding as you did with the Content-Type header. Make sure when you get the file from the server that the header is present and correct, and that the file hasn't been transcoded by the web server.


Use &#163;. I had the same problem and solved it using jQuery:

$(this).text('&amp;#163;');
  • If you try this and it does not work, just change the jQuery methods,
$(this).html('&amp;#163;');
  • This always work in all contexts...

This works in all chrome, IE, Firefox.

In Database > table > field type .for example set the symbol column TO varchar(2) utf8_bin php code:

$symbol = '£';
echo mb_convert_encoding($symbol, 'UTF-8', 'HTML-ENTITIES');
or 
html_entity_decode($symbol, ENT_NOQUOTES, 'UTF-8');

And also make sure set the HTML OR XML encoding to encoding="UTF-8"

Note: You should make sure that database, document type and php code all have a same encoding

How ever the better solution would be using &pound;


You need to save your PHP script file in UTF-8 encoding, and leave the <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> in the HTML.

For text editor, I recommend Notepad++, because it can detect and display the actual encoding of the file (in the lower right corner of the editor), and you can convert it as well.


Or for other code equivalents try:

&#163;
&pound;

Have you tried displaying a &pound; ?

Here is an overwhelming list.