http://www.perlmonks.org?node_id=858426


in reply to POSIX::strftime encoding

For what it's worth, I did the following :

use POSIX qw/setlocale LC_TIME strftime/; use Encode; my ($strftime_encoding)= setlocale(LC_TIME)=~m#\.([^@]+)#; sub strftime2 # try to return an utf8 value from strftime { $strftime_encoding ? Encode::decode($strftime_encoding, &strftime +) : &strftime; }

It works if the encoding is specified in the locale, which seems to be usually the case when using utf8.

And if the encoding is not in the locale, I keep the returned string as is, it won't work with all locales, but at least it works with fr_FR.

It's not perfect, but it's better than before, and simple.