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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|