note 78637 added to function.xml-parse
| From: | eewon at NOSPAMnowee dot org | Date: | Sat, 20 Oct 2007 16:21:04 +0000 |
| Subject: | note 78637 added to function.xml-parse | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131584@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.197
Probable Submitter: 90.27.200.149
----
Manual Page -- http://www.php.net/manual/en/function.xml-parse.php
Edit -- https://master.php.net/note/edit/78637
Del: integrated -- https://master.php.net/note/delete/78637/integrated
Del: useless -- https://master.php.net/note/delete/78637/useless
Del: bad code -- https://master.php.net/note/delete/78637/bad+code
Del: spam -- https://master.php.net/note/delete/78637/spam
Del: non-english -- https://master.php.net/note/delete/78637/non-english
Del: in docs -- https://master.php.net/note/delete/78637/in+docs
Del: other reasons-- https://master.php.net/note/delete/78637
Reject -- https://master.php.net/note/reject/78637
Search -- https://master.php.net/manage/user-notes.php