note 85034 added to function.utf8-decode

From: Date: Tue, 12 Aug 2008 11:40:47 +0000
Subject: note 85034 added to function.utf8-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-143386@lists.php.net to get a copy of this message
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 */ /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */ if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string)) return $string; // decode three byte unicode characters $string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e", \ "'&#'.((ord('\\1')-224)*4096 + (ord('\\2')-128)*64 + (ord('\\3')-128)).';'", \ $string); // decode two byte unicode characters $string = preg_replace("/([\300-\337])([\200-\277])/e", \ "'&#'.((ord('\\1')-192)*64+(ord('\\2')-128)).';'", \ $string); return $string; } ---- Server IP: 212.124.37.9 Probable Submitter: 80.128.41.140 ---- Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php Edit -- https://master.php.net/note/edit/85034 Del: integrated -- https://master.php.net/note/delete/85034/integrated Del: useless -- https://master.php.net/note/delete/85034/useless Del: bad code -- https://master.php.net/note/delete/85034/bad+code Del: spam -- https://master.php.net/note/delete/85034/spam Del: non-english -- https://master.php.net/note/delete/85034/non-english Del: in docs -- https://master.php.net/note/delete/85034/in+docs Del: other reasons-- https://master.php.net/note/delete/85034 Reject -- https://master.php.net/note/reject/85034 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143386) next »