Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: ASCII encoded unicode strings on web, such as \u00F3

by Anonymous Monk
on Jul 12, 2015 at 14:38 UTC ( [id://1134386]=note: print w/replies, xml ) Need Help??


in reply to Re^2: ASCII encoded unicode strings on web, such as \u00F3
in thread ASCII encoded unicode strings on web, such as \u00F3

Is your STDOUT in UTF-8 mode? (as in binmode STDOUT, ':encoding(utf-8), for example). That's the way to get 'normal Unicode' in Perl. Does this work for you:
my $str = 'encontr\u00e9 configuraci\u00f3n v\u00e1lidod'; $str =~ s/ \\u ( \p{Hex}{4} ) / chr hex $1 /gex; binmode STDOUT, ':encoding(utf-8)'; print $str, "\n";
?

Replies are listed 'Best First'.
Re^4: ASCII encoded unicode strings on web, such as \u00F3
by igoryonya (Pilgrim) on Jul 13, 2015 at 00:54 UTC
    Thanx, I did 'use utf8;', but binmode, fixed my problem. I am still struggling to understand unicode concepts. :(.
    With binmode, it works using ether hex or eval, also, I've tried pack('U', hex $1), it works.
    For some reason, I thought, pack 'U', takes hex digits as an argument, but actually I've had to convert it to decimal, because pack('U', $1) didn't work.

Log In?
Username:
Password:

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

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

    No recent polls found