cancel
Showing results for 
Search instead for 
Did you mean: 

Pound sign as £

decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Pound sign as £

In case anyone else experiences the same problem…

I have an HTML file on Hostopia that is displayed in an <iframe> on a ‘home pages’ server page.

From last week (3rd Apr onwards) sometime, the £ currency sign has been displaying as £. All other special characters seem OK

I assume this is a change (the PHP version change?) within Hostopia.

The problem is fixable by prefixing the HTML by <meta charset="UTF-8">

Zen from May 17. PN Business account from 2004 - 2017
5 REPLIES 5
jaread83
Community Gaffer
Community Gaffer
Posts: 3,438
Thanks: 2,336
Fixes: 81
Registered: ‎22-02-2016

Re: Pound sign as £

I have seen this happen to a number of websites I have worked on in the past and this generally occurs on pages where text has been copied directly from an MS Word document. Characters that are affected can be dashes, apostrophes, ampersands and currency (amongst many many others). Changing the meta to UTF-8 fixes them in most cases but not always. I personally character encode all special characters with the proper HTML references as working on ISO entity sets was the norm until about 7 years ago. This wikipedia article is probably the most visited of my bookmarks:

https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

Frontend Web Developer | www.plus.net

If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.

mikelahey
Pro
Posts: 236
Thanks: 88
Fixes: 12
Registered: ‎24-11-2015

Re: Pound sign as £

Have you escaped the character. The html should read &pound; rather than just have a pound sign character in the document. That way the browser will sort it out for you.

decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Re: Pound sign as £

If the HTML page were inline code then I would certainly have used &pound; 

But the page content is generated by the end-user, with PHP inserting some <div>s and appending an HTML prefix and suffix around whatever the user types in. In days gone by, PHP then FTPd this page to 'home pages' where it was displayed  within a container page via SSI. The move to Hostopia put paid to progammatic outbound FTPs, hence the use of an <iframe>. 

And to 

Zen from May 17. PN Business account from 2004 - 2017
mikelahey
Pro
Posts: 236
Thanks: 88
Fixes: 12
Registered: ‎24-11-2015

Re: Pound sign as £

Have you tried passing the user input string through the htmlentites() function in PHP. This will replace the characters in the string with the escaped equivalent. So & becomes &amp;

See: http://php.net/manual/en/function.htmlentities.php
decomplexity
Rising Star
Posts: 493
Thanks: 26
Registered: ‎30-07-2007

Re: Pound sign as £

Yes Mike - thanks.

Later-developed pages do indeed use htmlentities()  - and its inverse html_entitity_decode() when displaying the text for updating.

And lest anyone else has encountered the issue with PHP upgrade, it is not confined to <iframes>, but my workaround (in the original post) won't work for SSI-included text, because prefixing the SSI text by <meta charset="UTF-8"> is ignored, presumably because <meta> tags must be in <head> ... </head> and the SSI includes are in <body>...</body>. I just changed the charset of the SSI-including page to UTF-8 instead!

 

Zen from May 17. PN Business account from 2004 - 2017