note 104022 deleted from function.html-entity-decode by danbrown

From: Date: Wed, 18 May 2011 14:43:46 +0000
Subject: note 104022 deleted from function.html-entity-decode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179853@lists.php.net to get a copy of this message
Note Submitter: Ramil ---- Thanx Daniel its very useful. I use this function function utf8et ($string) { $string = preg_replace("/[\302-\375]([\001-\177])/", "&#65533;\\1", $string); $string = preg_replace("/[\340-\375].([\001-\177])/", "&#65533;\\1", $string); $string = preg_replace("/[\360-\375]..([\001-\177])/", "&#65533;\\1", $string); $string = preg_replace("/[\370-\375]...([\001-\177])/", "&#65533;\\1", $string); $string = preg_replace("/[\374-\375]....([\001-\177])/", "&#65533;\\1", $string); $string = preg_replace("/[\300-\301]./", "&#65533;", $string); $string = preg_replace("/\364[\220-\277]../", "&#65533;", $string); $string = preg_replace("/[\365-\367].../", "&#65533;", $string); $string = preg_replace("/[\370-\373]..../", "&#65533;", $string); $string = preg_replace("/[\374-\375]...../", "&#65533;", $string); $string = preg_replace("/[\376-\377]/", "&#65533;", $string); $string = preg_replace("/[\302-\364]{2,}/", "&#65533;", $string); $string = preg_replace( "/([\360-\364])([\200-\277])([\200-\277])([\200-\277])/e", "'&#'.((ord('\\1')&7)<<18 | (ord('\\2')&63)<<12 |" . " (ord('\\3')&63)<<6 | (ord('\\4')&63)).';'", $string); $string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e", "'&#'.((ord('\\1')&15)<<12 | (ord('\\2')&63)<<6 | (ord('\\3')&63)).';'", $string); $string = preg_replace("/([\300-\337])([\200-\277])/e", "'&#'.((ord('\\1')&31)<<6 | (ord('\\2')&63)).';'", $string); $string = preg_replace("/[\200-\277]/", "&#65533;", $string); return $string; } function utf8decode ($text) { $text= html_entity_decode($text,ENT_QUOTES,"UTF-8"); $text= preg_replace('/&#(\d+);/me',"chr(\\1)",$text); $text= preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)",$text); return $text; }

« previous php.notes (#179853) next »