Файл: sys/inc/utf8_convert_case.php
Строк: 27
<?php
function utf8_convert_case($s, $mode) {
static $trans = array(
"x41" => "x61",
"x42" => "x62",
"x43" => "x63",
"x44" => "x64",
"x45" => "x65",
"x46" => "x66",
"x47" => "x67",
"x48" => "x68",
"x49" => "x69",
"x4a" => "x6a",
"x4b" => "x6b",
"x4c" => "x6c",
"x4d" => "x6d",
"x4e" => "x6e",
"x4f" => "x6f",
"x50" => "x70",
"x51" => "x71",
"x52" => "x72",
"x53" => "x73",
"x54" => "x74",
"x55" => "x75",
"x57" => "x77",
"x56" => "x76",
"x58" => "x78",
"x59" => "x79",
"x5a" => "x7a",
"xd0x81" => "xd1x91",
"xd0x90" => "xd0xb0",
"xd0x91" => "xd0xb1",
"xd0x92" => "xd0xb2",
"xd0x93" => "xd0xb3",
"xd0x94" => "xd0xb4",
"xd0x95" => "xd0xb5",
"xd0x96" => "xd0xb6",
"xd0x97" => "xd0xb7",
"xd0x98" => "xd0xb8",
"xd0x99" => "xd0xb9",
"xd0x9a" => "xd0xba",
"xd0x9b" => "xd0xbb",
"xd0x9c" => "xd0xbc",
"xd0x9d" => "xd0xbd",
"xd0x9e" => "xd0xbe",
"xd0x9f" => "xd0xbf",
"xd0xa0" => "xd1x80",
"xd0xa1" => "xd1x81",
"xd0xa2" => "xd1x82",
"xd0xa3" => "xd1x83",
"xd0xa4" => "xd1x84",
"xd0xa5" => "xd1x85",
"xd0xa6" => "xd1x86",
"xd0xa7" => "xd1x87",
"xd0xa8" => "xd1x88",
"xd0xa9" => "xd1x89",
"xd0xaa" => "xd1x8a",
"xd0xab" => "xd1x8b",
"xd0xac" => "xd1x8c",
"xd0xad" => "xd1x8d",
"xd0xae" => "xd1x8e",
"xd0xaf" => "xd1x8f",
"xd2x96" => "xd2x97",
"xd2xa2" => "xd2xa3",
"xd2xae" => "xd2xaf",
"xd2xba" => "xd2xbb",
"xd3x98" => "xd3x99",
"xd3xa8" => "xd3xa9",
"xd2x90" => "xd2x91",
"xd0x84" => "xd1x94",
"xd0x86" => "xd1x96",
"xd0x87" => "xd1x97",
"xd0x8e" => "xd1x9e",
"xc3x84" => "xc3xa4",
"xc3x87" => "xc3xa7",
"xc3x91" => "xc3xb1",
"xc3x96" => "xc3xb6",
"xc3x9c" => "xc3xbc",
"xc4x9e" => "xc4x9f",
"xc4xb0" => "xc4xb1",
"xc5x9e" => "xc5x9f",
"xc4x8c" => "xc4x8d",
"xc4x86" => "xc4x87",
"xc4x90" => "xc4x91",
"xc5xa0" => "xc5xa1",
"xc5xbd" => "xc5xbe",
"xc3x80" => "xc3xa0",
"xc3x82" => "xc3xa2",
"xc3x86" => "xc3xa6",
"xc3x88" => "xc3xa8",
"xc3x89" => "xc3xa9",
"xc3x8a" => "xc3xaa",
"xc3x8b" => "xc3xab",
"xc3x8e" => "xc3xae",
"xc3x8f" => "xc3xaf",
"xc3x94" => "xc3xb4",
"xc5x92" => "xc5x93",
"xc3x99" => "xc3xb9",
"xc3x9b" => "xc3xbb",
"xc5xb8" => "xc3xbf",
);
if ($mode == CASE_UPPER) {
if (function_exists('mb_strtoupper'))
return mb_strtoupper($s, 'utf-8');
if (preg_match('/^[x00-x7e]*$/', $s))
return strtoupper($s);
strtr($s, array_flip($trans));
}
elseif ($mode == CASE_LOWER) {
if (function_exists('mb_strtolower'))
return mb_strtolower($s, 'utf-8');
if (preg_match('/^[x00-x7e]*$/', $s))
return strtolower($s);
strtr($s, $trans);
}
else {
trigger_error('Parameter 2 should be a constant of CASE_LOWER or CASE_UPPER!', E_USER_WARNING);
return $s;
}
return $s;
}
function utf8_lowercase($s) {
return utf8_convert_case($s, CASE_LOWER);
}
function utf8_uppercase($s) {
return utf8_convert_case($s, CASE_UPPER);
}
?>