• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

£ 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

0
Daniish
Asked:
Daniish
4 Solutions
 
cr4ck3rj4ckCommented:
This should work for you:

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

Open in new window

0
 
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now