Note that setlocale
will use the first locale from your given list that it can find. Most likely the fr_FR
locale matches first and is not using UTF-8, and/or you do not have the UTF-8 variants of that locale installed at all and/or you got their names wrong. Check your installed locales with locale -a
(CLI command) and prioritise the UTF-8 versions before generic versions like fr_FR
.
My locales:
$ locale -a | grep fr_FR
fr_FR
fr_FR.ISO8859-1
fr_FR.ISO8859-15
fr_FR.UTF-8
Therefore:
setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR', 'French');
To demonstrate the difference it makes:
$ php -r 'setlocale(LC_TIME, "fr_FR.ISO8859-1"); echo strftime("%A %B");'
Vendredi f?vrier
$ php -r 'setlocale(LC_TIME, "fr_FR.UTF-8"); echo strftime("%A %B");'
Vendredi février
If strange characters are returned use utf8_encode(strftime()) for UTF-8 characters
– Debflav Feb 6 '15 at 8:57utf8_encode
is a bandaid, not a proper fix. It should be your last resort to patch every invocation ofstrftime
with it. Fixing your locales should be the primary goal. – deceze♦ Feb 6 '15 at 8:59