ext/PerlIO/Scalar/Makefile.PL PerlIO layer for scalars
ext/PerlIO/Scalar/Scalar.pm PerlIO layer for scalars
ext/PerlIO/Scalar/Scalar.xs PerlIO layer for scalars
+ext/PerlIO/t/encoding.t See if PerlIo encoding conversion works
ext/PerlIO/t/scalar.t Test of PerlIO::Scalar
ext/PerlIO/Via/Makefile.PL PerlIO layer for layers in perl
ext/PerlIO/Via/Via.pm PerlIO layer for layers in perl
C<Encode> provides a "layer" (See L<perliol>) which can transform
data as it is read or written.
+Here is how the blind poet would modernise the encoding:
+
use Encode;
- open(my $ilyad,'>:encoding(iso-8859-7)','ilyad.greek');
- print $ilyad @epic;
+ open(my $iliad,'<:encoding(iso-8859-7)','iliad.greek');
+ open(my $utf8,'>:utf8','iliad.utf8');
+ my @epic = <$iliad>;
+ print $utf8 @epic;
+ close($utf8);
+ close($illiad);
In addition the new IO system can also be configured to read/write
UTF-8 encoded characters (as noted above this is efficient):
--- /dev/null
+my $grk = "grk$$";
+my $utf = "utf$$";
+
+if (open(GRK, ">$grk")) {
+ # alpha beta gamma in ISO 8859-7
+ print GRK "\xe1\xe2\xe3";
+ close GRK;
+}
+
+{
+ use Encode;
+ open(my $i,'<:encoding(iso-8859-7)',$grk);
+ print "ok 1\n";
+ open(my $o,'>:utf8',$utf);
+ print "ok 2\n";
+ print $o readline($i);
+ print "ok 3\n";
+ close($o);
+ close($i);
+}
+
+if (open(UTF, "<$utf")) {
+ # alpha beta gamma in UTF-8 Unicode (0x3b1 0x3b2 0x3b3)
+ print "not " unless <UTF> eq "\xce\xb1\xce\xb2\xce\xb3";
+ print "ok 4\n";
+ close $grk;
+}
+
+{
+ use Encode;
+ open(my $i,'<:utf8',$utf);
+ print "ok 5\n";
+ open(my $o,'>:encoding(iso-8859-7)',$grk);
+ print "ok 6\n";
+ print $o readline($i);
+ print "ok 7\n";
+ close($o);
+ close($i);
+}
+
+if (open(GRK, "<$grk")) {
+ print "not " unless <GRK> eq "\xe1\xe2\xe3";
+ print "ok 8\n";
+ close $grk;
+}
+
+END {
+ unlink($grk, $utf);
+}