CPAN-Meta-YAML

 view release on metacpan or  search on metacpan

lib/CPAN/Meta/YAML.pm  view on Meta::CPAN

        if ( utf8::is_utf8($string) && ! utf8::valid($string) ) {
            die \<<'...';
Read an invalid UTF-8 string (maybe mixed UTF-8 and 8-bit character set).
Did you decode with lax ":utf8" instead of strict ":encoding(UTF-8)"?
...
        }

        # Ensure Unicode character semantics, even for 0x80-0xff
        utf8::upgrade($string);

        # Check for and strip any leading UTF-8 BOM
        $string =~ s/^\x{FEFF}//;

        # Check for some special cases
        return $self unless length $string;

        # Split the file into lines
        my @lines = grep { ! /^\s*(?:\#.*)?\z/ }
                split /(?:\015{1,2}\012|\015|\012)/, $string;

        # Strip the initial YAML header

t/10_read.t  view on Meta::CPAN

            [ 'foo' ]
        ],
    },
    'multibyte UTF-8' => {
        file => 'multibyte.yml',
        perl => [
            { author => 'Ævar Arnfjörð Bjarmason <avar@cpan.org>' }
        ],
        utf8 => 'author',
    },
    'UTF-8 BOM' => {
        file => 'utf_8_bom.yml',
        perl => [
            { author => 'Ævar Arnfjörð Bjarmason <avar@cpan.org>' }
        ],
        utf8 => 'author',
    },
);

for my $key ( sort keys %passes ) {
    subtest $key => sub {

t/lib/TestUtils.pm  view on Meta::CPAN


sub test_data_file {
    return File::Spec->catfile( test_data_directory(), shift );
}

sub slurp {
    my $file = shift;
    local $/ = undef;
    open( FILE, " $file" ) or die "open($file) failed: $!";
    binmode( FILE, $_[0] ) if @_ > 0;
    # binmode(FILE); # disable perl's BOM interpretation
    my $source = <FILE>;
    close( FILE ) or die "close($file) failed: $!";
    $source;
}

1;



( run in 0.670 second using v1.01-cache-2.11-cpan-f29a10751f0 )