note 74905 added to function.utf8-encode
| From: | nikoooadogbkadotru-Nickolaz at osu1 dot php dot net | Date: | Thu, 03 May 2007 14:02:26 +0000 |
| Subject: | note 74905 added to function.utf8-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126145@lists.php.net to get a copy of this message | ||
You can use this simple code to convert win-1251 into Unicode.
function rus2uni($str,$isTo = true)
{
$arr =
array('Ñ'=>'ё','Ð'=>'Ё');
for($i=192;$i<256;$i++)
$arr[chr($i)] = ''.dechex($i-176).';';
$str =preg_replace(array('@([а-Ñ]) @i','@
([а-Ñ])@i'),array('$1 ',' $1'),$str);
return strtr($str,$isTo?$arr:array_flip($arr));
}
That is useful for xml_parser (to parse windows-1251 files like utf-8).
----
Server IP: 195.54.192.44
Probable Submitter: 62.141.80.211
----
Manual Page -- http://www.php.net/manual/en/function.utf8-encode.php
Edit -- https://master.php.net/note/edit/74905
Del: integrated -- https://master.php.net/note/delete/74905/integrated
Del: useless -- https://master.php.net/note/delete/74905/useless
Del: bad code -- https://master.php.net/note/delete/74905/bad+code
Del: spam -- https://master.php.net/note/delete/74905/spam
Del: non-english -- https://master.php.net/note/delete/74905/non-english
Del: in docs -- https://master.php.net/note/delete/74905/in+docs
Del: other reasons-- https://master.php.net/note/delete/74905
Reject -- https://master.php.net/note/reject/74905
Search -- https://master.php.net/manage/user-notes.php