Re: ampersand in dom with utf-8

From: Date: Thu, 13 Oct 2005 11:53:17 +0000
Subject: Re: ampersand in dom with utf-8
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-224032@lists.php.net to get a copy of this message
maybe i should have said: &egrave; is not an _xml_ entity. i m not very sure. sorry. `&egrave;' is an html entity, represents the letter `è' in iso-8859-1 charset, which have ascii value of 0xe8 . to have it recognized by libxml, there are 3 ways to do this: 1, <?xml version="1.0"><item_name>&#e8;</item_name> 2, <?xml version="1.0" encoding="iso-8859-1"><item_name>è</item_name> 3, <?xml version="1.0"><item_name>è</item_name> 1 can be saved using either utf-8 encoding or iso-8859-1 encoding; 2 must be saved using iso-8859-1 encoding 3 must be saved using utf-8 encoding ( to have `è' be converted properly) in php, we can do this: $html = html_entity_decode('<item_name>farm lettuces with reed avocado, cr&egrave;me fra&icirc;che, radish and cilantro</item_name>'); $dom = DomDocument::loadXML("<?xml version=\"1.0\" encoding=\"iso-8859-1\">$html"); On 10/13/05, Marcus Bointon <marcus@synchromedia.co.uk> wrote: > On 13 Oct 2005, at 07:24, cc wrote: > > > both &egrave;' and &icirc;' are not > > entities in charset utf-8, use > > &amp;egrave;' and &amp;icirc;' instead. > > I would expect that to result in unconverted entities in the output. > If you're intending to send that content as HTML, then I guess that > would be OK. However, if you're using UTF-8 anyway, why not just use > the real characters? > > Marcus > -- > Marcus Bointon > Synchromedia Limited: Putting you in the picture > marcus@synchromedia.co.uk | http://www.synchromedia.co.uk > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#224032) next »