note 98697 added to function.html-entity-decode
| From: | Free at Key dot no | Date: | Thu, 01 Jul 2010 12:51:46 +0000 |
| Subject: | note 98697 added to function.html-entity-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-170618@lists.php.net to get a copy of this message | ||
Handy function to convert remaining HTML-entities into human readable chars (for entities which do
not exist in target charset):
function cleanString($in,$offset=null)
{
$out = trim($in);
if (!empty($out))
{
$entity_start = strpos($out,'&',$offset);
if ($entity_start === false)
{
// ideal
return $out;
}
else
{
$entity_end = strpos($out,';',$entity_start);
if ($entity_end === false)
{
return $out;
}
// zu lang um eine entity zu sein
else if ($entity_end > $entity_start+7)
{
// und weiter gehts
$out = cleanString($out,$entity_start+1);
}
// gottcha!
else
{
$clean = substr($out,0,$entity_start);
$subst = substr($out,$entity_start+1,1);
// š => "s" / š => "_"
$clean .= ($subst != "#") ? $subst : "_";
$clean .= substr($out,$entity_end+1);
// und weiter gehts
$out = cleanString($clean,$entity_start+1);
}
}
}
return $out;
}
----
Server IP: 69.147.83.197
Probable Submitter: 77.59.235.98
----
Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php
Edit -- https://master.php.net/note/edit/98697
Del: integrated -- https://master.php.net/note/delete/98697/integrated
Del: useless -- https://master.php.net/note/delete/98697/useless
Del: bad code -- https://master.php.net/note/delete/98697/bad+code
Del: spam -- https://master.php.net/note/delete/98697/spam
Del: non-english -- https://master.php.net/note/delete/98697/non-english
Del: in docs -- https://master.php.net/note/delete/98697/in+docs
Del: other reasons-- https://master.php.net/note/delete/98697
Reject -- https://master.php.net/note/reject/98697
Search -- https://master.php.net/manage/user-notes.php