note 72272 added to function.html-entity-decode

From: Date: Wed, 10 Jan 2007 13:11:09 +0000
Subject: note 72272 added to function.html-entity-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-121525@lists.php.net to get a copy of this message
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; ?> ---- Server IP: 194.153.94.10 Probable Submitter: 195.49.42.250 ---- Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php Edit -- https://master.php.net/note/edit/72272 Del: integrated -- https://master.php.net/note/delete/72272/integrated Del: useless -- https://master.php.net/note/delete/72272/useless Del: bad code -- https://master.php.net/note/delete/72272/bad+code Del: spam -- https://master.php.net/note/delete/72272/spam Del: non-english -- https://master.php.net/note/delete/72272/non-english Del: in docs -- https://master.php.net/note/delete/72272/in+docs Del: other reasons-- https://master.php.net/note/delete/72272 Reject -- https://master.php.net/note/reject/72272 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#121525) next »