1

Topic: setlocale (LC_TIME, null) returns "C"

Debian 8 + php 5.6 . In system all are installed necessary :
[spoiler]

wrote:

locale-a
C
C.UTF-8
en_US.utf8
POSIX
ru_RU
ru_RU.cp1251
ru_RU.iso88595
ru_RU.koi8r
ru_RU.utf8
russian

wrote:

locale
LANG=ru_RU.UTF-8
LANGUAGE=ru_RU:ru
LC_CTYPE = "ru_RU.UTF-8"
LC_NUMERIC = "ru_RU.UTF-8"
LC_TIME = "ru_RU.UTF-8"
LC_COLLATE = "ru_RU.UTF-8"
LC_MONETARY = "ru_RU.UTF-8"
LC_MESSAGES = "ru_RU.UTF-8"
LC_PAPER = "ru_RU.UTF-8"
LC_NAME = "ru_RU.UTF-8"
LC_ADDRESS = "ru_RU.UTF-8"
LC_TELEPHONE = "ru_RU.UTF-8"
LC_MEASUREMENT = "ru_RU.UTF-8"
LC_IDENTIFICATION = "ru_RU.UTF-8"
LC_ALL=ru_RU.UTF-8

[/spoiler]
Further in a php-code I check:

setlocale (LC_TIME, ' en_US.UTF-8 ');
die (strftime (' %b %d, %Y %I: % M: % S %p ', time ()));//Dec 01, 2016 0:11:27 PM AM
//setlocale (LC_TIME, null)//A C
//setlocale (LC_ALL, null)//A C
setlocale (LC_TIME, ' ru_RU.UTF-8 ');
die (strftime (' %b %d, %Y %I: % M: % S %p ', time ()));//a deque 01, 2016 0:06:22 PM
//setlocale (LC_TIME, null)//A C
//setlocale (LC_ALL, null)//A C

In this code in both cases specified  are correctly applied.
But thus " setlocale (LC_ALL, null) " in both cases returns  "C". Why?
According to to help :

wrote:

If in quality locale the blank line "" or NULL is transferred, names  will be are taken from the variables of a surrounding with the same name or by a variable with a name "LANG" .
If in quality locale it is transferred NULL or "0",  it will not be changed, and current value will be returned.

In this case we explicitly install  LC_TIME , we check that it was correctly installed (is correctly used by function strftime ) and there and then we receive its value - but we receive "C". Why?

2

Re: setlocale (LC_TIME, null) returns "C"

Well here also understood. Checked up and in Debian , and in Windows -  the artifact of equally shows and in php 5.4 , and in php 5.6 .
In help function setlocale is described incorrectly. More truly, Russian-speaking transfer includes  (about null ).
In to help in Russian variant it is written:

wrote:

If in quality locale the blank line "" or NULL is transferred, names  will be are taken from the variables of a surrounding with the same name or a variable with a name "LANG".
If in quality locale it is transferred NULL or "0" ,  it will not be changed, and current value will be returned.

Further we look an English-speaking variant:

wrote:

If locale is NULL or the empty string "", the locale names will be set from the values of environment variables with the same names as the above categories, or from "LANG".
If locale is "0" , the locale setting is not affected, only the current setting is returned.

I.e., according to an English-speaking (original) variant, at usage null   it will be changed (the same as and at blank line usage). Also it will be returned not leaking , and changed. With it understood.
Further. In both variants of translation it is specified that at usage "" (and also at usage null as we just clarified) it will be installed and returned , taken of variables of a surrounding or from Lang. If truth is a question of variables of a surrounding of an operating system, it not. At least, for php 5.4 and above. Namely: at usage "" or null function installs and returns system  by default - that which is applied in an operating system right after setting before any adjustments  ( in Linux is 7-bit English-speaking  "With", in Windows - "Russian_Russia.1251" ). Irrespective of the fact which  it is installed at level of variables of a surrounding.
---

http://www.navioo.com/php/docs/function.setlocale.php wrote:

When i tried to get the current locale (e.g. after i set the lang to german with setlocale (LC_ALL, ' de_DE ');), the following did not work on my suse linux 9.0-box:
$currentLocale = setlocale (LC_ALL, NULL);
This code did a reset to the server-setting .
$currentLocale = setlocale (LC_ALL, 0); works perfectly for me, but the manual says NULL and 0 are equal in this case, but NULL seems to act like "" .

3

Re: setlocale (LC_TIME, null) returns "C"

There are without an explanation following facts :
1. In English-speaking comments to to help on function setlocale are resulted working code fragments in which for obtaining leaking  the parameter null , instead of 0 is used.
2. Practically all forum and  engines (CMS) for obtaining leaking  use parameter null , instead of 0. As a result of their code   is unoperated.
It is possible to explain the Current pattern so :
1. Initially (to the version php 5.4 ) leaking  it was possible to receive and with parameter 0, and with parameter null . But since the version php 5.4 - only with parameter 0. Thus original (English-speaking) help has been modified, and Russian-speaking transfer remained without changes.
2. At the moment of transfer of help into Russian it was revealed, as at parameter usage null function also returns leaking  (as well as at usage 0 ). As a result in Russian translation near to 0 has been attributed and null . But from the version php 5.4 null ceased to work as 0 . But the current assumption does not explain presence in comments to official help working code fragments in which for obtaining leaking  the parameter null is used.
I tend to 1 variant.
P.S . For obtaining leaking  (without change of this) it is possible to use and numerical parameter 0, and string "0".