xref: /openbsd-src/gnu/usr.bin/perl/ext/PerlIO-encoding/encoding.pm (revision 5c389b79544373bccfce668b646e62e7ba9802a3)
1package PerlIO::encoding;
2
3use strict;
4our $VERSION = '0.30';
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 = Encode::PERLQQ()|Encode::WARN_ON_ERR()|Encode::ONLY_PRAGMA_WARNINGS();
17
181;
19__END__
20
21=head1 NAME
22
23PerlIO::encoding - encoding layer
24
25=head1 SYNOPSIS
26
27  use PerlIO::encoding;
28
29  open($f, "<:encoding(foo)", "infoo");
30  open($f, ">:encoding(bar)", "outbar");
31
32  use Encode qw(:fallbacks);
33  $PerlIO::encoding::fallback = FB_PERLQQ;
34
35=head1 DESCRIPTION
36
37This PerlIO layer opens a filehandle with a transparent encoding filter.
38
39On input, it converts the bytes expected to be in the specified
40character set and encoding to Perl string data (Unicode and
41Perl's internal Unicode encoding, UTF-8).  On output, it converts
42Perl string data into the specified character set and encoding.
43
44When the layer is pushed, the current value of C<$PerlIO::encoding::fallback>
45is saved and used as the CHECK argument when calling the Encode methods
46encode() and decode().
47
48=head1 SEE ALSO
49
50L<open>, L<Encode>, L<perlfunc/binmode>, L<perluniintro>
51
52=cut
53