note 103433 added to function.mb-decode-numericentity

From: Date: Wed, 13 Apr 2011 09:46:07 +0000
Subject: note 103433 added to function.mb-decode-numericentity
Groups: php.notes 
Request: Send a blank email to php-notes+get-178788@lists.php.net to get a copy of this message
When I use this function, I had found an error. Example) ------------------------ INPUT STRING1 : abc& INPUT STRING2 : abc&# ------------------------ OUTPUT STRING : abc ------------------------ <?php $input = 'abc&'; $convmap = array (0x0, 0xffff, 0, 0xffff); $output = mb_decode_numericentity($intput, $convmap, 'UTF-8'); echo $output; ?> result : abc If an input string is finished with some characters such the beginning of NCR-form, this function remove that characters. So, I use an trick. <?php function decode_numericentity($string){ $string = $string.chr(32); $string = mb_decode_numericentity($string, $convmap, 'UTF-8'); $pos = strlen($string)-1; //if(ord($string[$pos]) == 32){ $string = substr($string,0,$pos); //} return $string; } ?> ---- Server IP: 219.255.134.115 Probable Submitter: 61.106.160.16 ---- Manual Page -- http://www.php.net/manual/en/function.mb-decode-numericentity.php Edit -- https://master.php.net/note/edit/103433 Del: integrated -- https://master.php.net/note/delete/103433/integrated Del: useless -- https://master.php.net/note/delete/103433/useless Del: bad code -- https://master.php.net/note/delete/103433/bad+code Del: spam -- https://master.php.net/note/delete/103433/spam Del: non-english -- https://master.php.net/note/delete/103433/non-english Del: in docs -- https://master.php.net/note/delete/103433/in+docs Del: other reasons-- https://master.php.net/note/delete/103433 Reject -- https://master.php.net/note/reject/103433 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178788) next »