On 2010-07-20 00:11:55, TODDR wrote:
Show quoted text> I spoke with Avar about this. The plan is to update the documentation
> to clarify that if you are
> expected to open the file handle as UTF8 if you expect wide chars to
> be in the structure:
>
> open(my $fh, ">:encoding(UTF-8)", "out.yml") or die
> DumpFile($fh, $hashref);
>
Sorry, I have to re-open this ticket. Using this is not enough to get a
dump/load roundtrip working (see below).
Also, I don't like it that the user has to do something special to have
wide character serialization correct. I think there should be a way to
detect the presence of wide characters automatically and do the right thing?
Regards,
Slaven
#!/usr/bin/perl -w
use strict;
use Test::More 'no_plan';
use YAML::Syck qw(DumpFile LoadFile);
my $test = ["\x{20ac}"];
open(my $fh, ">:encoding(UTF-8)", "/tmp/test.yml");
DumpFile $fh, $test;
close $fh or die $!;
my $test2 = LoadFile "/tmp/test.yml";
is_deeply($test2,$test);
__END__
$ perl5.12.0 /tmp/yamlsyck.pl
not ok 1
# Failed test at /tmp/yamlsyck.pl line 12.
Wide character in print at /usr/perl5.12.0/lib/5.12.0/Test/Builder.pm
line 1753.
# Structures begin differing at:
# $got->[0] = 'âÃÂì'
# $expected->[0] = 'â¬'
1..1
# Looks like you failed 1 test of 1.
Exitcode 1