Subject: | DumpFile does not write in utf8 |
YAML::Tiny::DumpFile does not write YAML files using the UTF-8 encoding.
Instead it uses the default platform encoding (which on Windows is not
UTF-8).
Subject: | 22_utf8.t |
use utf8;
use Test::More tests => 6;
use YAML::Tiny qw/DumpFile LoadFile/;
ok defined &DumpFile,
'DumpFile exported';
ok defined &LoadFile,
'LoadFile exported';
my $file = 't/dump.yaml';
# A scalar containing non-ASCII characters
my $data = 'Olivier Mengué';
is length($data), 14, 'Test source is correctly encoded';
DumpFile($file, $data);
ok -e $file,
'Output file exists';
open IN, '<:utf8', $file or die $!;
my $yaml = do { local $/; <IN> };
close IN;
is $yaml, "--- '$data'\n", 'DumpFile YAML encoding is correct';
my $read = LoadFile($file);
is $read, $data, 'LoadFile is ok';
unlink $file;