note 72272 deleted from function.html-entity-decode by danbrown

From: Date: Tue, 10 Jan 2012 20:12:49 +0000
Subject: note 72272 deleted from function.html-entity-decode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185536@lists.php.net to get a copy of this message
Note Submitter: elektronaut gmx.net ---- I made my own fix to allow numerical entities in utf8 in php4... <? function utf8_replaceEntity($result){ $value = (int)$result[1]; $string = ''; $len = round(pow($value,1/8)); for($i=$len;$i>0;$i--){ $part = ($value & (255>>2)) | pow(2,7); if ( $i == 1 ) $part |= 255<<(8-$len); $string = chr($part) . $string; $value >>= 6; } return $string; } function utf8_html_entity_decode($string){ return preg_replace_callback( '/&#([0-9]+);/u', 'utf8_replaceEntity', $string ); } $string = '&#8217;&#8216; &#8211; &#8220; &#8221;' .'&#61607; &#263; &#324; &#345;' ; $string = utf8_html_entity_decode($string,null,'UTF-8'); header('Content-Type: text/html; charset=UTF-8'); echo '<li>'.$string; ?>

« previous php.notes (#185536) next »