Use of locale dependent functions has to be replaced by their counterparts in mb_* library [Yii2]

Yii2 uses locale dependent functions (like strtolower or strtoupper) all over the framework. In some cases locale may affect the behavior of these functions even in the range of ASCII (0-127). For instance:


$locale = setlocale(LC_CTYPE, "tr_TR.ISO-8859-9");

if ($locale)

	echo (strtolower('en-IE') == 'en-ie') ? 'TRUE' : 'FALSE';

else

	echo 'Could not set locale';


// result >> FALSE

Furthermore, as stated in PHP documentation for setlocale():

Also, it must kept in mind that string functions may get overloaded by mb_* functions using mbstring.func_overload directive in php.ini. In this case the behavior mostly depends on mb_internal_encoding() setting and obviously one may not rely on it.

My verdict: Yii2 use of locale dependent string functions has to be replaced by their counterparts in mb_* library and by explicitly specifying the corresponding encoding like the following:


mb_strtolower($string, 'ISO-8859-1');

mb_strtoupper($string, 'UTF-8');