note 60021 added to function.html-entity-decode

From: Date: Fri, 23 Dec 2005 04:33:08 +0000
Subject: note 60021 added to function.html-entity-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-100605@lists.php.net to get a copy of this message
I shortened the function repace_num_entity a bit to make more understandable and clean. Maybe now someone sees the problem it possibly has... (as mentioned below) <?php function replace_num_entity($ord) { $ord = $ord[1]; if (preg_match('/^x([0-9a-f]+)$/i', $ord, $match)) $ord = hexdec($match[1]); else $ord = intval($ord); $no_bytes = 0; $byte = array(); if ($ord < 128) return chr($ord); if ($ord < 2048) $no_bytes = 2; else if ($ord < 65536) $no_bytes = 3; else if ($ord < 1114112) $no_bytes = 4; else return; switch($no_bytes) { case 2: $prefix = array(31, 192); break; case 3: $prefix = array(15, 224); break; case 4: $prefix = array(7, 240); } for ($i=0; $i < $no_bytes; ++$i) $byte[$no_bytes-$i-1] = (($ord & (63 * pow(2,6*$i))) / pow(2,6*$i)) & 63 | 128; $byte[0] = ($byte[0] & $prefix[0]) | $prefix[1]; $ret = ''; for ($i=0; $i < $no_bytes; ++$i) $ret .= chr($byte[$i]); return $ret; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60021 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60021&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60021&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60021&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60021&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60021&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60021&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60021&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60021&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100605) next »