Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: string conversion problem

by aitap (Chaplain)
on Mar 07, 2013 at 07:36 UTC ( #1022163=note: print w/ replies, xml ) Need Help??


in reply to string conversion problem

The result of uri_unescape contains bytes, not characters:

$ perl -Mutf8 -MURI::Escape -E'say utf8::is_utf8(uri_unescape shift) ? + "characters" : "bytes"' %E4%BA%8E%E6%96%AF%E5%B1%88%E8%BE%BE%E5%B0%9 +4 bytes
Perhaps you need to decode these bytes to the internal character representation and then encode them on output as you need:
$ perl -MEncode=decode -MData::Dumper -MURI::Escape -e 'print Dumper d +ecode utf8 => uri_unescape shift' %E4%BA%8E%E6%96%AF%E5%B1%88%E8%BE%B +E%E5%B0%94 $VAR1 = "\x{4e8e}\x{65af}\x{5c48}\x{8fbe}\x{5c14}";
Once you have characters instead of bytes you can encode them as you want using :encoding IOLayer or encode function from Encode module.
Sorry if my advice was wrong.


Comment on Re: string conversion problem
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-04-17 05:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (439 votes), past polls