Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2015-07-06 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls