Skip to content

Instantly share code, notes, and snippets.

@xaicron
Created December 9, 2009 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xaicron/252604 to your computer and use it in GitHub Desktop.
Save xaicron/252604 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Encode qw/encode decode find_encoding/;
use Benchmark qw/timethese cmpthese/;
my $bytes = '小飼弾はアルファブロガー';
my $enc = find_encoding 'utf8';
cmpthese timethese 0, {
normal => sub {
my $str = decode utf8 => $bytes;
my $_bytes = encode utf8 => $str;
},
find_encoding => sub {
my $str = $enc->decode($bytes);
my $_bytes = $enc->encode($str);
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment