Well, eval is clearly the looser, chr wins:

use Benchmark qw(cmpthese); my $S = 'Compruebe si las direcciones URL que encontr\u00e9 en el arch +ivo de configuraci\u00f3n son v\u00e1lidos'; cmpthese(1e6, { eval => sub { $_ = $S; s/\\u([0-9a-fA-F]{4})/eval "\"\\x{$1}\" +"/ge; }, chr => sub { $_ = $S; s/\\u([0-9a-fA-F]{4})/chr hex $1/ge; }, pack => sub { $_ = $S; s/\\u([0-9a-fA-F]{4})/pack 'U', hex $1/ +ge; } } ); __END__ Rate eval pack chr eval 38865/s -- -84% -88% pack 242131/s 523% -- -28% chr 336700/s 766% 39% -- # without eval Rate pack chr pack 242131/s -- -27% chr 330033/s 36% --

which is reasonable, since chr is more specialized than pack and should have less overhead (otherwise chr would have been implemented in terms of pack).

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re^4: ASCII encoded unicode strings on web, such as \u00F3 by shmem
in thread ASCII encoded unicode strings on web, such as \u00F3 by igoryonya

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.