Skip to content

Instantly share code, notes, and snippets.

@tagomoris
Created October 20, 2011 06:07
Show Gist options
  • Save tagomoris/1300534 to your computer and use it in GitHub Desktop.
Save tagomoris/1300534 to your computer and use it in GitHub Desktop.
Encode::decode_utf($str, 1) bug?
use Data::Dumper;
my $x = {1 => "ichi", 2 => "ni"};
warn Dumper $x;
{
use Encode;
my $decoded = Encode::decode_utf8($x->{1}, 1);
local $x->{1} = $decoded;
warn Dumper $x;
}
warn Dumper $x;
# $ perl -MEncode -E 'say $Encode::VERSION'
# 2.42
###### output
# $VAR1 = {
# '1' => 'ichi',
# '2' => 'ni'
# };
# $VAR1 = {
# '1' => 'ichi',
# '2' => 'ni'
# };
# $VAR1 = {
# '1' => '',
# '2' => 'ni'
# };
@tagomoris
Copy link
Author

使いかたの問題だった。
checkに Encode::LEAVE_SRC を渡せばよい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment