// Setting up system locale
$locales = array("ru_RU.CP1251", "ru_RU.cp1251", "ru_RU", "RU");
$localeSet = false;
foreach ($locales as $localeName) {
if ((bool)$localeSet === false) {
// setting up locase
setlocale(LC_ALL, $localeName);
}
// check locale
if ((bool)$localeSet === false && strtolower("qwertyёЁАБГДЯQWERTYZ") == "qwertyёёабгдяqwertyz") {
// locale setup correctly
$localeSet = true;
}
}
if ((bool)$localeSet !== true) {
// exiting now
echo "Can't set up server locale to cp1251 character set at ".__FILE__." on ".__LINE__;
exit();
}