note 119280 added to function.utf8-decode

From: Date: Mon, 02 May 2016 18:09:54 +0000
Subject: note 119280 added to function.utf8-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-205416@lists.php.net to get a copy of this message
Update Answer from okx dot oliver dot koenig at gmail dot com for PHP 5.6 since e/ modifier is depreciated // This finally helped me to do the job, thanks to Blackbit, had to modify deprecated ereg: // original comment: "Squirrelmail contains a nice function in the sources to convert unicode to entities:" function charset_decode_utf_8($string) { /* Only do the slow convert if there are 8-bit characters */ if ( !preg_match("/[\200-\237]/", $string) && !preg_match("/[\241-\377]/", $string) ) return $string; // decode three byte unicode characters $string = preg_replace_callback("/([\340-\357])([\200-\277])([\200-\277])/", create_function ('$matches', 'return \'&#\'.((ord($matches[1])-224)*4096+(ord($matches[2])-128)*64+(ord($matches[3])-128)).\';\';'), $string); // decode two byte unicode characters $string = preg_replace_callback("/([\300-\337])([\200-\277])/", create_function ('$matches', 'return \'&#\'.((ord($matches[1])-192)*64+(ord($matches[2])-128)).\';\';'), $string); return $string; } Enjoy ---- Server IP: 72.52.91.14 Probable Submitter: 109.221.57.147 ---- Manual Page -- http://php.net/manual/en/function.utf8-decode.php Edit -- https://master.php.net/note/edit/119280 Del: integrated -- https://master.php.net/note/delete/119280/integrated Del: useless -- https://master.php.net/note/delete/119280/useless Del: bad code -- https://master.php.net/note/delete/119280/bad+code Del: spam -- https://master.php.net/note/delete/119280/spam Del: non-english -- https://master.php.net/note/delete/119280/non-english Del: in docs -- https://master.php.net/note/delete/119280/in+docs Del: other reasons-- https://master.php.net/note/delete/119280 Reject -- https://master.php.net/note/reject/119280 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205416) next »