Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mozork1's avatar

Does setlocale() affect POST or REQUEST data?

My understanding was that it controlled the generation of locale specific content e.g., date formats, etc.

It was suggested to me that the problem I'm seeing related to utf-8 request data decoding COULD be related to locale, i.e., that locale can affect how utf-8 is decoded into codepoints https://xender.vip/ .

Is this possible?

On a bit of a tangent: On php7.4 (+ Apache 2.4), I'm seeing something odd:

The default 'LANG' in envvars is 'C'. This is reflected in the return of setlocale(LC_CTYPE,0);

When I change it to "en_US.UTF-8", restart apache and php-fpm, a call to setlocale(LC_CTYPE,0) will reflect the change. BUT..., at some point, on successive requests, the setlocale() call will flip back to returning 'C'. It ain't me doing it..., and it doesn't appear to be any of the modules I'm using either.

FWIW..., threads are not enabled

0 likes
0 replies

Please or to participate in this conversation.