£ is an invalid entity - what do i replace it with ?

Hello,

I use the attached code to catch invalid entities from data held in mysql. I would like to add a line to this code to catch the pound symbol ' £ '

What should this be replaced with?

Where can i find a complete list of valid entities in case i need to add any other dodgy characters ?


Many thanks
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','&lt;',$htmlStr);
$xmlStr=str_replace('>','&gt;',$xmlStr);
$xmlStr=str_replace('"','&quot;',$xmlStr);
$xmlStr=str_replace("'",'&apos;',$xmlStr);
$xmlStr=str_replace("&",'&amp;',$xmlStr);
$xmlStr=str_replace(chr(0x20).chr(0x10), '&#x2010;', $xmlStr);
return(htmlspecialchars(str_replace("#","<br /><br />",$htmlStr), ENT_QUOTES));
return $xmlStr;
}

Open in new window

DaniishAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cr4ck3rj4ckCommented:
This should work for you:

$xmlStr=str_replace('£','&pound;',$xmlStr);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cr4ck3rj4ckCommented:
For additional characters, check out: http://www.ascii.cl/htmlcodes.htm
0
hieloCommented:
replace it with:

&#163; 
the friendly name is not a "standard" xml entity.

Open in new window

0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

NoiSCommented:
First

htmlspecialchars don't convert all chars, just a few like < >;

Use htmlentities instead.

Second
Everytime that you need special chars inside a XML use CDATA

<tag><![CDATA[YOUR CONTENTS GOES HERE]]></tag>
0
DaniishAuthor Commented:
Thank you all for your suggestions - i have tried both of the following:

$xmlStr=str_replace('£','&#163;',$xmlStr);
$xmlStr=str_replace('£','&pound;',$xmlStr);

but neither have the desired effect, what could be going wrong ?

If you wish to see the currently unconverted symbols - please visit:
www.globexposure.net/index.php
Then click on the England pushpin marker > the Norwich (SE England) Arrow marker > airplane icon
You will see in the right hand column that 3x £ symbols aren't being displayed!


Thanks again

p.s. excellent link cr4ck3rj4ck :)
0
DaniishAuthor Commented:
I forgot to apply the replacement of special characters to the individual attributes being returned from my database - all sorted now.

Many thanks :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.