Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: strftime does not handle Unicode characters in format argument properly (at least, not consistently)

by choroba (Cardinal)
on Sep 21, 2020 at 19:08 UTC ( [id://11122025]=note: print w/replies, xml ) Need Help??


in reply to strftime does not handle Unicode characters in format argument properly (at least, not consistently)

When I add use utf8; and correctly set the encoding of the output, it seems to work:
#!/usr/bin/perl use strict; use warnings; use utf8; use open OUT => ':encoding(UTF-8)', ':std'; use POSIX qw(strftime); my $string = 'hailed an über ‘cab’ on '; my @t = (0, 0, 0, 23, 5, 2020, 4); my $nbsp = chr 160; print $string . strftime( '%d/%b', @t), "\n"; print $string . strftime( "%d$nbsp%b", @t), "\n"; print $string . strftime("‘%d$nbsp%b’", @t), "\n"; print $string . strftime('‘%d %b’', @t), "\n";

Update: I used the $nbsp here, as PerlMonk replaces the non-breakable space with a normal ASCII space, but it works with the nbsp character directly in the script, too.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re: strftime does not handle Unicode characters in format argument properly (at least, not consistently)
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-26 04:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found