xref: /openbsd-src/gnu/usr.bin/perl/ext/PerlIO-encoding/encoding.pm (revision 5a38ef86d0b61900239c7913d24a05e7b88a58f0)
1package PerlIO::encoding;
2
3use strict;
4our $VERSION = '0.28';
5our $DEBUG = 0;
6$DEBUG and warn __PACKAGE__, " called by ", join(", ", caller), "\n";
7
8#
9# Equivalent of this is done in encoding.xs - do not uncomment.
10#
11# use Encode ();
12
13require XSLoader;
14XSLoader::load();
15
16our $fallback =
17    Encode::PERLQQ()|Encode::WARN_ON_ERR()|Encode::ONLY_PRAGMA_WARNINGS()|Encode::STOP_AT_PARTIAL();
18
191;
20__END__
21
22=head1 NAME
23
24PerlIO::encoding - encoding layer
25
26=head1 SYNOPSIS
27
28  use PerlIO::encoding;
29
30  open($f, "<:encoding(foo)", "infoo");
31  open($f, ">:encoding(bar)", "outbar");
32
33  use Encode qw(:fallbacks);
34  $PerlIO::encoding::fallback = FB_PERLQQ;
35
36=head1 DESCRIPTION
37
38This PerlIO layer opens a filehandle with a transparent encoding filter.
39
40On input, it converts the bytes expected to be in the specified
41character set and encoding to Perl string data (Unicode and
42Perl's internal Unicode encoding, UTF-8).  On output, it converts
43Perl string data into the specified character set and encoding.
44
45When the layer is pushed, the current value of C<$PerlIO::encoding::fallback>
46is saved and used as the CHECK argument when calling the Encode methods
47encode() and decode().
48
49=head1 SEE ALSO
50
51L<open>, L<Encode>, L<perlfunc/binmode>, L<perluniintro>
52
53=cut
54