note 118076 added to function.setlocale
| From: | ShashakhmetovTalgat | Date: | Tue, 29 Sep 2015 16:41:54 +0000 |
| Subject: | note 118076 added to function.setlocale | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203877@lists.php.net to get a copy of this message | ||
//Fix encoding for russian locale on windows
$locale = setlocale(LC_ALL, 'ru_RU.CP1251', 'rus_RUS.CP1251',
'Russian_Russia.1251');
function strftime_fix($format, $locale, $timestamp = time()){
// Fix %e for windows
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
}
// convert
$date_str = strftime($format, $timestamp);
if (stripos($locale, "1251") !== false) {
return iconv("windows-1251","utf-8", $date_str);
} elseif (stripos($locale, "1252") !== false) {
return iconv("windows-1252","utf-8", $date_str);
} else {
return $date_str;
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 88.206.119.192
----
Manual Page -- http://php.net/manual/en/function.setlocale.php
Edit -- https://master.php.net/note/edit/118076
Del: integrated -- https://master.php.net/note/delete/118076/integrated
Del: useless -- https://master.php.net/note/delete/118076/useless
Del: bad code -- https://master.php.net/note/delete/118076/bad+code
Del: spam -- https://master.php.net/note/delete/118076/spam
Del: non-english -- https://master.php.net/note/delete/118076/non-english
Del: in docs -- https://master.php.net/note/delete/118076/in+docs
Del: other reasons-- https://master.php.net/note/delete/118076
Reject -- https://master.php.net/note/reject/118076
Search -- https://master.php.net/manage/user-notes.php