File-Map
view release on metacpan or search on metacpan
t/20-unicode.t view on Meta::CPAN
map_anonymous my $mapped, length $example;
is(warnings { substr $mapped, 0, length $example, $example }, 0, 'Assigning to $mapped gives no error');
ok !utf8::is_utf8($mapped), 'Mapped memory is bytes, not characters';
utf8::decode($example) or die 'Can\'t decode $example';
is(warnings { utf8::decode($mapped) }, 0, 'Can decode mapped');
ok utf8::is_utf8($mapped), 'Mapped memory is decoded to characters';
is $mapped, $example, '$mapped eq $example';
for my $var (substr $mapped, 0, length $mapped) {
is(warnings { $var = uc $var }, 0, 'Indirect capitolization gives no warnings');
}
my $cap_example = 'HÃLLÃ WÃRLD';
is $mapped, $cap_example, '$mapped is now capitalized';
t/20-unicode.t view on Meta::CPAN
is $mapped, lc $example, 'mapped is lowercased';
{
open my $fh, '<:raw:utf8', $0;
my $utf_mapped;
is(warnings { map_handle $utf_mapped, $fh }, 0, 'Can map utf8 handle without warnings');
ok utf8::is_utf8($utf_mapped), 'Mapped memory is decoded to characters automatically';
}
{
my $utf_mapped;
is(warnings { map_file $utf_mapped, $0, '<:raw:utf8' }, 0, 'Can map utf8 file without warnings');
ok utf8::is_utf8($utf_mapped), 'Mapped memory is decoded to characters automatically';
}
( run in 0.273 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )