Skip to content

Commit 756189a

Browse files
committed
PerlIO on EBCDIC on BS2000 advice from Thomas Dorner.
(This information looks interesting enough to be mentioned elsewhere, too.) p4raw-id: //depot/perl@20903
1 parent 0c45d62 commit 756189a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.bs2000

+34
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,40 @@ Perl code:
174174
Although one would expect the quantities $y and $z to be the same and equal
175175
to 100000 they will differ and instead will be 0 and 100000 respectively.
176176

177+
=head2 Using PerlIO and different encodings on ASCII and EBCDIC partitions
178+
179+
Since version 5.8 Perl uses the new PerlIO on BS2000. This enables
180+
you using different encodings per IO channel. For example you may use
181+
182+
use Encode;
183+
open($f, ">:encoding(ascii)", "test.ascii");
184+
print $f "Hello World!\n";
185+
open($f, ">:encoding(posix-bc)", "test.ebcdic");
186+
print $f "Hello World!\n";
187+
open($f, ">:encoding(latin1)", "test.latin1");
188+
print $f "Hello World!\n";
189+
open($f, ">:encoding(utf8)", "test.utf8");
190+
print $f "Hello World!\n";
191+
192+
to get two files containing "Hello World!\n" in ASCII, EBCDIC, ISO
193+
Latin-1 (in this example identical to ASCII) respective UTF-EBCDIC (in
194+
this example identical to normal EBCDIC). See the documentation of
195+
Encode::PerlIO for details.
196+
197+
As the PerlIO layer uses raw IO internally, all this totally ignores
198+
the type of your filesystem (ASCII or EBCDIC) and the IO_CONVERSION
199+
environment variable. If you want to get the old behavior, that the
200+
BS2000 IO functions determine conversion depending on the filesystem
201+
PerlIO still is your friend. You use IO_CONVERSION as usual and tell
202+
Perl, that it should use the native IO layer:
203+
204+
export IO_CONVERSION=YES
205+
export PERLIO=stdio
206+
207+
Now your IO would be ASCII on ASCII partitions and EBCDIC on EBCDIC
208+
partitions. See the documentation of PerlIO (without C<Encode::>!)
209+
for further posibilities.
210+
177211
=head1 AUTHORS
178212

179213
Thomas Dorner

0 commit comments

Comments
 (0)