note 78637 deleted from function.xml-parse by danbrown
| From: | danbrown@php.net | Date: | Wed, 12 Oct 2011 23:20:22 +0000 |
| Subject: | note 78637 deleted from function.xml-parse by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183837@lists.php.net to get a copy of this message | ||
Note Submitter: eewon at NOSPAMnowee dot org
----
Whilst implementing my RSS_FEED reader, I stumbled upon a slight issue, typically on RSS feeds such
as the NY Times ones : quotes and apostrophes were replaced by question tags. For example :
"the creator?s" instead of "the creator's" due to the use of ’
for that reason I used the following simple trick to make sure all these HTML entities would be
converted correctly :
function code2code($data)
{
$trans = array(
'‘'=>'‘',
'’'=>'’',
'“'=>'“',
'”'=>'”',
'•'=>'•',
'–'=>'–',
'—'=>'—');
return strtr($data, $trans);
}
while($data=fread($fp,4096))
{
xml_parse($xml_parser,code2code($data),feof($fp));
}
fclose($fp);
I'm sure it can be done better, and that it lacks some other entries, yet it works for me.