doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Explain that C is the default locale

Open saulery opened this issue 3 years ago • 1 comments

Hello,

Maybe on setlocale() page, explains that C is now the default locale and that setting one is not recommended anymore. Recommend to use Locale::setDefault() from Intl and mbstring instead, according to https://wiki.php.net/rfc/strtolower-ascii#why_do_applications_call_setlocale

Locale sensitivity is not useful for natural language processing in new code. We have the intl and mbstring extensions for that.

PHP libraries distributed with Packagist or PEAR cannot assume a particular locale. Setting the locale temporarily is discouraged by the PHP manual, because the locale is a true global and will influence other threads in a multithreaded SAPI. So libraries have a choice of either reimplementing these core string functions, or just calling them and hoping.

And https://www.php.net/manual/fr/migration80.incompatible.php#migration80.incompatible.standard

The default locale on startup is now always "C". No locales are inherited from the environment by default. Previously, LC_ALL was set to "C", while LC_CTYPE was inherited from the environment. However, some functions did not respect the inherited locale without an explicit setlocale() call. An explicit setlocale() call is now always required if a locale component should be changed from the default.

Regards,

saulery avatar Sep 23 '22 12:09 saulery

Indeed, it makes sense to clarify that.

cmb69 avatar Sep 26 '22 09:09 cmb69