Skip to content

Commit

Permalink
Clarify that users must do UTF-8 encoding/decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
xdg committed Dec 13, 2011
1 parent 553dce0 commit 396c803
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Revision history for CPAN-Meta-YAML

{{$NEXT}}

- Fix documentation to clarify that users are responsible for
UTF-8 encoding/decoding

0.004 2011-09-06 09:42:52 America/New_York

- Generated from ADAMK/YAML-Tiny-1.50.tar.gz
Expand Down
24 changes: 14 additions & 10 deletions pod/lib/CPAN/Meta/YAML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@
use CPAN::Meta::YAML;
# methods for files
$yaml = CPAN::Meta::YAML->read('META.yml');
$yaml->write('MYMETA.yml');
# methods for strings
$yaml_text = $yaml->write_string;
$yaml = CPAN::Meta::YAML->read_string($yaml_text);
# reading a META file
open $fh, "<:utf8", "META.yml";
$yaml_text = do { local $/; <$fh> };
$yaml = CPAN::Meta::YAML->read_string($yaml_text)
or die CPAN::Meta::YAML->errstr;
# finding the metadata
my $meta = $yaml->[0];
$meta = $yaml->[0];
# handling errors
$yaml->write($file)
# writing a META file
$yaml_text = $yaml->write_string
or die CPAN::Meta::YAML->errstr;
open $fh, ">:utf8", "META.yml";
print $fh $yaml_text;
=head1 DESCRIPTION
This module implements a subset of the YAML specification for use in reading
and writing CPAN metadata files like F<META.yml> and F<MYMETA.yml>. It should
not be used for any other general YAML parsing or generation task.
NOTE: META.yml (and MYMETA.yml) files should be UTF-8 encoded. Users are
responsible for proper encoding and decoding. In particular, the C<read> and
C<write> methods do B<not> support UTF-8 and should not be used.
=head1 SUPPORT
This module is currently derived from L<YAML::Tiny> by Adam Kennedy. If
Expand Down

0 comments on commit 396c803

Please sign in to comment.