xref: /openbsd-src/gnu/usr.bin/perl/ext/PerlIO-encoding/encoding.pm (revision 3d61058aa5c692477b6d18acfbbdb653a9930ff9)
143003dfeSmillertpackage PerlIO::encoding;
243003dfeSmillert
343003dfeSmillertuse strict;
4*3d61058aSafresh1our $VERSION = '0.31';
543003dfeSmillertour $DEBUG = 0;
643003dfeSmillert$DEBUG and warn __PACKAGE__, " called by ", join(", ", caller), "\n";
743003dfeSmillert
843003dfeSmillert#
943003dfeSmillert# Equivalent of this is done in encoding.xs - do not uncomment.
1043003dfeSmillert#
1143003dfeSmillert# use Encode ();
1243003dfeSmillert
13898184e3Ssthenrequire XSLoader;
14898184e3SsthenXSLoader::load();
1543003dfeSmillert
16eac174f2Safresh1our $fallback = Encode::PERLQQ()|Encode::WARN_ON_ERR()|Encode::ONLY_PRAGMA_WARNINGS();
1743003dfeSmillert
1843003dfeSmillert1;
1943003dfeSmillert__END__
2043003dfeSmillert
2143003dfeSmillert=head1 NAME
2243003dfeSmillert
2343003dfeSmillertPerlIO::encoding - encoding layer
2443003dfeSmillert
2543003dfeSmillert=head1 SYNOPSIS
2643003dfeSmillert
2743003dfeSmillert  use PerlIO::encoding;
2843003dfeSmillert
2943003dfeSmillert  open($f, "<:encoding(foo)", "infoo");
3043003dfeSmillert  open($f, ">:encoding(bar)", "outbar");
3143003dfeSmillert
3243003dfeSmillert  use Encode qw(:fallbacks);
3343003dfeSmillert  $PerlIO::encoding::fallback = FB_PERLQQ;
3443003dfeSmillert
3543003dfeSmillert=head1 DESCRIPTION
3643003dfeSmillert
3743003dfeSmillertThis PerlIO layer opens a filehandle with a transparent encoding filter.
3843003dfeSmillert
3943003dfeSmillertOn input, it converts the bytes expected to be in the specified
4043003dfeSmillertcharacter set and encoding to Perl string data (Unicode and
4143003dfeSmillertPerl's internal Unicode encoding, UTF-8).  On output, it converts
4243003dfeSmillertPerl string data into the specified character set and encoding.
4343003dfeSmillert
4443003dfeSmillertWhen the layer is pushed, the current value of C<$PerlIO::encoding::fallback>
4543003dfeSmillertis saved and used as the CHECK argument when calling the Encode methods
4643003dfeSmillertencode() and decode().
4743003dfeSmillert
4843003dfeSmillert=head1 SEE ALSO
4943003dfeSmillert
5043003dfeSmillertL<open>, L<Encode>, L<perlfunc/binmode>, L<perluniintro>
5143003dfeSmillert
5243003dfeSmillert=cut
53