Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: POSIX::strftime encoding

by squentin (Sexton)
on Sep 01, 2010 at 22:07 UTC ( #858426=note: print w/ replies, xml ) Need Help??

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.

Comment on Re: POSIX::strftime encoding
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://858426]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2016-05-28 18:15 GMT
Find Nodes?
    Voting Booth?