note 83158 added to function.convert-cyr-string
| From: | web at uit dot kiev dot ua | Date: | Tue, 13 May 2008 13:51:16 +0000 |
| Subject: | note 83158 added to function.convert-cyr-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139331@lists.php.net to get a copy of this message | ||
convert text back from utf8 to windows 1251 (russian and ukrainian letters)
function Utf8ToWin($fcontents) {
$out = $c1 = '';
$byte2 = false;
for ($c = 0;$c < strlen($fcontents);$c++) {
$i = ord($fcontents[$c]);
if ($i <= 127) {
$out .= $fcontents[$c];
}
if ($byte2) {
$new_c2 = ($c1 & 3) * 64 + ($i & 63);
$new_c1 = ($c1 >> 2) & 5;
$new_i = $new_c1 * 256 + $new_c2;
if ($new_i == 1025) {
$out_i = 168;
} else {
if ($new_i == 1105) {
$out_i = 184;
} else {
$out_i = $new_i - 848;
}
}
// UKRAINIAN fix
switch ($out_i){
case 262: $out_i=179;break;// Ñ
case 182: $out_i=178;break;// Ð
case 260: $out_i=186;break;// Ñ
case 180: $out_i=170;break;// Ð
case 263: $out_i=191;break;// Ñ
case 183: $out_i=175;break;// Ð
case 321: $out_i=180;break;// Ò
case 320: $out_i=165;break;// Ò
}
$out .= chr($out_i);
$byte2 = false;
}
if ( ( $i >> 5) == 6) {
$c1 = $i;
$byte2 = true;
}
}
return $out;
}
----
Server IP: 69.147.83.197
Probable Submitter: 217.27.152.94 (proxied: 127.0.0.1)
----
Manual Page -- http://www.php.net/manual/en/function.convert-cyr-string.php
Edit -- https://master.php.net/note/edit/83158
Del: integrated -- https://master.php.net/note/delete/83158/integrated
Del: useless -- https://master.php.net/note/delete/83158/useless
Del: bad code -- https://master.php.net/note/delete/83158/bad+code
Del: spam -- https://master.php.net/note/delete/83158/spam
Del: non-english -- https://master.php.net/note/delete/83158/non-english
Del: in docs -- https://master.php.net/note/delete/83158/in+docs
Del: other reasons-- https://master.php.net/note/delete/83158
Reject -- https://master.php.net/note/reject/83158
Search -- https://master.php.net/manage/user-notes.php