UPDATE never mind, couldn't reproduce the problem at home, uri_escape_utf8() works like documented. Seems to be due to problems at work.

Hi

I'm trying to process unicode-strings in the same way in JS and Perl.

According to URI::Escape

Note: JavaScript has a function called escape() that produces the sequence "%uXXXX" for chars in the 256 .. 65535 range. This function has really nothing to do with URI escaping but some folks got confused since it "does the right thing" in the 0 .. 255 range. Because of this you sometimes see "URIs" with these kind of escapes. The JavaScript encodeURIComponent() function is similar to uri_escape_utf8().

But my tests show that this might be wrong, encodeURIComponent() produces rather the same like &uri_escape.

JS:

[19:05:09.782] encodeURIComponent("ダニエル") [19:05:09.789] "%E3%83%80%E3%83%8B%E3%82%A8%E3%83%AB"

Perl:

DB<48> p uri_escape("&#12480;&#12491;&#12456;&#12523;") %E3%83%80%E3%83%8B%E3%82%A8%E3%83%AB DB<49> p uri_escape_utf8("&#12480;&#12491;&#12456;&#12523;") %C3%A3%C2%83%C2%80%C3%A3%C2%83%C2%8B%C3%A3%C2%82%C2%A8%C3%A3%C2%83%C2% +AB

Am I missing something or is that a bug in the documentation?

Cheers Rolf

PS: seems like the monastery doesn't like 3 Byte Unicodes, those characters were from a Japanese page.


In reply to same UTF8 escaping in JS and Perl? (solved) by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.