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