Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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 making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2016-04-30 00:57 GMT
Find Nodes?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW

    Results (441 votes). Check out past polls.