note 74905 deleted from function.utf8-encode by cmb

From: Date: Sun, 04 Dec 2016 12:12:23 +0000
Subject: note 74905 deleted from function.utf8-encode by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208196@lists.php.net to get a copy of this message
Note Submitter: nikooo adog bk adot ru - Nickolaz ---- You can use this simple code to convert win-1251 into Unicode. function rus2uni($str,$isTo = true) { $arr = array('ё'=>'&#x451;','Ё'=>'&#x401;'); for($i=192;$i<256;$i++) $arr[chr($i)] = '&#x4'.dechex($i-176).';'; $str =preg_replace(array('@([а-я]) @i','@ ([а-я])@i'),array('$1&#x0a0;','&#x0a0;$1'),$str); return strtr($str,$isTo?$arr:array_flip($arr)); } That is useful for xml_parser (to parse windows-1251 files like utf-8).

« previous php.notes (#208196) next »