Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by shmem (Chancellor)
on Jul 13, 2015 at 11:34 UTC ( [id://1134478]=note: print w/replies, xml ) Need Help??


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

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'

Log In?
Username:
Password:

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

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

    No recent polls found