Why Can't I Display A Pound (£) Symbol In Html?
Solution 1:
Educated guess: You have a ISO-8859-1 encoded pound sign in a UTF-8 encoded page.
Make sure your data is in the right encoding and everything will work fine.
Solution 2:
Use £
. I had the same problem and solved it using jQuery:
$(this).text('£');
- If you try this and it does not work, just change the jQuery methods,
$(this).html('£');
- This always work in all contexts...
Solution 3:
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'£';
5th: javascript solutions:
document.getElementById('id_goes_here').innerText.replace('£','£');
document.getElementById('id_goes_here').innerText.replace('£',"\u00A3");
$(this).html().replace('£','£'); //jquery
$(this).html().replace('£',"\u00A3"); //jqueryString.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.
Solution 4:
Have you tried displaying a £
?
Here is an overwhelming list.
Solution 5:
You could try using £
or £
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.
Post a Comment for "Why Can't I Display A Pound (£) Symbol In Html?"