Debian Codegraph @

upstream/mageia-cauldron/man1/perlebcdic.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "PERLEBCDIC 1"
61 .TH PERLEBCDIC 1 2025-06-24 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 perlebcdic \- Considerations for running Perl on EBCDIC platforms
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 An exploration of some of the issues facing Perl programmers
71 on EBCDIC based computers.
72 .PP
73 Portions of this document that are still incomplete are marked with XXX.
74 .PP
75 Early Perl versions worked on some EBCDIC machines, but the last known
76 version that ran on EBCDIC was v5.8.7, until v5.22, when the Perl core
77 again works on z/OS. Theoretically, it could work on OS/400 or Siemens\*(Aq
78 BS2000 (or their successors), but this is untested. In v5.22 and 5.24,
79 not all
80 the modules found on CPAN but shipped with core Perl work on z/OS.
81 .PP
82 If you want to use Perl on a non\-z/OS EBCDIC machine, please let us know
83 at <https://github.com/Perl/perl5/issues>.
84 .PP
85 Writing Perl on an EBCDIC platform is really no different than writing
86 on an "ASCII" one, but with different underlying numbers, as we\*(Aqll see
87 shortly. You\*(Aqll have to know something about those "ASCII" platforms
88 because the documentation is biased and will frequently use example
89 numbers that don\*(Aqt apply to EBCDIC. There are also very few CPAN
90 modules that are written for EBCDIC and which don\*(Aqt work on ASCII;
91 instead the vast majority of CPAN modules are written for ASCII, and
92 some may happen to work on EBCDIC, while a few have been designed to
93 portably work on both.
94 .PP
95 If your code just uses the 52 letters A\-Z and a\-z, plus SPACE, the
96 digits 0\-9, and the punctuation characters that Perl uses, plus a few
97 controls that are denoted by escape sequences like \f(CW\*(C`\en\*(C'\fR and \f(CW\*(C`\et\*(C'\fR, then
98 there\*(Aqs nothing special about using Perl, and your code may very well
99 work on an ASCII machine without change.
100 .PP
101 But if you write code that uses \f(CW\*(C`\e005\*(C'\fR to mean a TAB or \f(CW\*(C`\exC1\*(C'\fR to mean
102 an "A", or \f(CW\*(C`\exDF\*(C'\fR to mean a "ÿ" (small \f(CW"y"\fR with a diaeresis),
103 then your code may well work on your EBCDIC platform, but not on an
104 ASCII one. That\*(Aqs fine to do if no one will ever want to run your code
105 on an ASCII platform; but the bias in this document will be towards writing
106 code portable between EBCDIC and ASCII systems. Again, if every
107 character you care about is easily enterable from your keyboard, you
108 don\*(Aqt have to know anything about ASCII, but many keyboards don\*(Aqt easily
109 allow you to directly enter, say, the character \f(CW\*(C`\exDF\*(C'\fR, so you have to
110 specify it indirectly, such as by using the \f(CW"\exDF"\fR escape sequence.
111 In those cases it\*(Aqs easiest to know something about the ASCII/Unicode
112 character sets. If you know that the small "ÿ" is \f(CW\*(C`U+00FF\*(C'\fR, then
113 you can instead specify it as \f(CW"\eN{U+FF}"\fR, and have the computer
114 automatically translate it to \f(CW\*(C`\exDF\*(C'\fR on your platform, and leave it as
115 \&\f(CW\*(C`\exFF\*(C'\fR on ASCII ones. Or you could specify it by name, \f(CW\*(C`\eN{LATIN
116 SMALL LETTER Y WITH DIAERESIS\*(C'\fR and not have to know the numbers.
117 Either way works, but both require familiarity with Unicode.
118 .SH "COMMON CHARACTER CODE SETS"
119 .IX Header "COMMON CHARACTER CODE SETS"
120 .SS ASCII
121 .IX Subsection "ASCII"
122 The American Standard Code for Information Interchange (ASCII or
123 US\-ASCII) is a set of
124 integers running from 0 to 127 (decimal) that have standardized
125 interpretations by the computers which use ASCII. For example, 65 means
126 the letter "A".
127 The range 0..127 can be covered by setting various bits in a 7\-bit binary
128 digit, hence the set is sometimes referred to as "7\-bit ASCII".
129 ASCII was described by the American National Standards Institute
130 document ANSI X3.4\-1986. It was also described by ISO 646:1991
131 (with localization for currency symbols). The full ASCII set is
132 given in the table below as the first 128 elements.
133 Languages that
134 can be written adequately with the characters in ASCII include
135 English, Hawaiian, Indonesian, Swahili and some Native American
136 languages.
137 .PP
138 Most non\-EBCDIC character sets are supersets of ASCII. That is the
139 integers 0\-127 mean what ASCII says they mean. But integers 128 and
140 above are specific to the character set.
141 .PP
142 Many of these fit entirely into 8 bits, using ASCII as 0\-127, while
143 specifying what 128\-255 mean, and not using anything above 255.
144 Thus, these are single\-byte (or octet if you prefer) character sets.
145 One important one (since Unicode is a superset of it) is the ISO 8859\-1
146 character set.
147 .SS "ISO 8859"
148 .IX Subsection "ISO 8859"
149 The ISO 8859\-\fR\f(CB$n\fR\f(BI\fR\fI\fR are a collection of character code sets from the
150 International Organization for Standardization (ISO), each of which adds
151 characters to the ASCII set that are typically found in various
152 languages, many of which are based on the Roman, or Latin, alphabet.
153 Most are for European languages, but there are also ones for Arabic,
154 Greek, Hebrew, and Thai. There are good references on the web about
155 all these.
156 .SS "Latin 1 (ISO 8859\-1)"
157 .IX Subsection "Latin 1 (ISO 8859-1)"
158 A particular 8\-bit extension to ASCII that includes grave and acute
159 accented Latin characters. Languages that can employ ISO 8859\-1
160 include all the languages covered by ASCII as well as Afrikaans,
161 Albanian, Basque, Catalan, Danish, Faroese, Finnish, Norwegian,
162 Portuguese, Spanish, and Swedish. Dutch is covered albeit without
163 the ij ligature. French is covered too but without the oe ligature.
164 German can use ISO 8859\-1 but must do so without German\-style
165 quotation marks. This set is based on Western European extensions
166 to ASCII and is commonly encountered in World Wide Web work.
167 In IBM character code set identification terminology, ISO 8859\-1 is
168 also known as CCSID 819 (or sometimes 0819 or even 00819).
169 .SS EBCDIC
170 .IX Subsection "EBCDIC"
171 The Extended Binary Coded Decimal Interchange Code refers to a
172 large collection of single\- and multi\-byte coded character sets that are
173 quite different from ASCII and ISO 8859\-1, and are all slightly
174 different from each other; they typically run on host computers. The
175 EBCDIC encodings derive from 8\-bit byte extensions of Hollerith punched
176 card encodings, which long predate ASCII. The layout on the
177 cards was such that high bits were set for the upper and lower case
178 alphabetic
179 characters \f(CW\*(C`[a\-z]\*(C'\fR and \f(CW\*(C`[A\-Z]\*(C'\fR, but there were gaps within each Latin
180 alphabet range, visible in the table below. These gaps can
181 cause complications.
182 .PP
183 Some IBM EBCDIC character sets may be known by character code set
184 identification numbers (CCSID numbers) or code page numbers.
185 .PP
186 Perl can be compiled on platforms that run any of three commonly used EBCDIC
187 character sets, listed below.
188 .PP
189 \fIThe 13 variant characters\fR
190 .IX Subsection "The 13 variant characters"
191 .PP
192 Among IBM EBCDIC character code sets there are 13 characters that
193 are often mapped to different integer values. Those characters
194 are known as the 13 "variant" characters and are:
195 .PP
196 .Vb 1
197 \& \e [ ] { } ^ ~ ! # | $ @ \`
198 .Ve
199 .PP
200 When Perl is compiled for a platform, it looks at all of these characters to
201 guess which EBCDIC character set the platform uses, and adapts itself
202 accordingly to that platform. If the platform uses a character set that is not
203 one of the three Perl knows about, Perl will either fail to compile, or
204 mistakenly and silently choose one of the three.
205 .PP
206 The Line Feed (LF) character is actually a 14th variant character, and
207 Perl checks for that as well.
208 .PP
209 \fIEBCDIC code sets recognized by Perl\fR
210 .IX Subsection "EBCDIC code sets recognized by Perl"
211 .IP \fB0037\fR 4
212 .IX Item "0037"
213 Character code set ID 0037 is a mapping of the ASCII plus Latin\-1
214 characters (i.e. ISO 8859\-1) to an EBCDIC set. 0037 is used
215 in North American English locales on the OS/400 operating system
216 that runs on AS/400 computers. CCSID 0037 differs from ISO 8859\-1
217 in 236 places; in other words they agree on only 20 code point values.
218 .IP \fB1047\fR 4
219 .IX Item "1047"
220 Character code set ID 1047 is also a mapping of the ASCII plus
221 Latin\-1 characters (i.e. ISO 8859\-1) to an EBCDIC set. 1047 is
222 used under Unix System Services for OS/390 or z/OS, and OpenEdition
223 for VM/ESA. CCSID 1047 differs from CCSID 0037 in eight places,
224 and from ISO 8859\-1 in 236.
225 .IP \fBPOSIX\-BC\fR 4
226 .IX Item "POSIX-BC"
227 The EBCDIC code page in use on Siemens\*(Aq BS2000 system is distinct from
228 1047 and 0037. It is identified below as the POSIX\-BC set.
229 Like 0037 and 1047, it is the same as ISO 8859\-1 in 20 code point
230 values.
231 .SS "Unicode code points versus EBCDIC code points"
232 .IX Subsection "Unicode code points versus EBCDIC code points"
233 In Unicode terminology a \fIcode point\fR is the number assigned to a
234 character: for example, in EBCDIC the character "A" is usually assigned
235 the number 193. In Unicode, the character "A" is assigned the number 65.
236 All the code points in ASCII and Latin\-1 (ISO 8859\-1) have the same
237 meaning in Unicode. All three of the recognized EBCDIC code sets have
238 256 code points, and in each code set, all 256 code points are mapped to
239 equivalent Latin1 code points. Obviously, "A" will map to "A", "B" =>
240 "B", "%" => "%", etc., for all printable characters in Latin1 and these
241 code pages.
242 .PP
243 It also turns out that EBCDIC has nearly precise equivalents for the
244 ASCII/Latin1 C0 controls and the DELETE control. (The C0 controls are
245 those whose ASCII code points are 0..0x1F; things like TAB, ACK, BEL,
246 etc.) A mapping is set up between these ASCII/EBCDIC controls. There
247 isn\*(Aqt such a precise mapping between the C1 controls on ASCII platforms
248 and the remaining EBCDIC controls. What has been done is to map these
249 controls, mostly arbitrarily, to some otherwise unmatched character in
250 the other character set. Most of these are very very rarely used
251 nowadays in EBCDIC anyway, and their names have been dropped, without
252 much complaint. For example the EO (Eight Ones) EBCDIC control
253 (consisting of eight one bits = 0xFF) is mapped to the C1 APC control
254 (0x9F), and you can\*(Aqt use the name "EO".
255 .PP
256 The EBCDIC controls provide three possible line terminator characters,
257 CR (0x0D), LF (0x25), and NL (0x15). On ASCII platforms, the symbols
258 "NL" and "LF" refer to the same character, but in strict EBCDIC
259 terminology they are different ones. The EBCDIC NL is mapped to the C1
260 control called "NEL" ("Next Line"; here\*(Aqs a case where the mapping makes
261 quite a bit of sense, and hence isn\*(Aqt just arbitrary). On some EBCDIC
262 platforms, this NL or NEL is the typical line terminator. This is true
263 of z/OS and BS2000. In these platforms, the C compilers will swap the
264 LF and NEL code points, so that \f(CW"\en"\fR is 0x15, and refers to NL. Perl
265 does that too; you can see it in the code chart below.
266 This makes things generally "just work" without you even having to be
267 aware that there is a swap.
268 .SS "Unicode and UTF"
269 .IX Subsection "Unicode and UTF"
270 UTF stands for "Unicode Transformation Format".
271 UTF\-8 is an encoding of Unicode into a sequence of 8\-bit byte chunks, based on
272 ASCII and Latin\-1.
273 The length of a sequence required to represent a Unicode code point
274 depends on the ordinal number of that code point,
275 with larger numbers requiring more bytes.
276 UTF\-EBCDIC is like UTF\-8, but based on EBCDIC.
277 They are enough alike that often, casual usage will conflate the two
278 terms, and use "UTF\-8" to mean both the UTF\-8 found on ASCII platforms,
279 and the UTF\-EBCDIC found on EBCDIC ones.
280 .PP
281 You may see the term "invariant" character or code point.
282 This simply means that the character has the same numeric
283 value and representation when encoded in UTF\-8 (or UTF\-EBCDIC) as when
284 not. (Note that this is a very different concept from "The 13 variant
285 characters" mentioned above. Careful prose will use the term "UTF\-8
286 invariant" instead of just "invariant", but most often you\*(Aqll see just
287 "invariant".) For example, the ordinal value of "A" is 193 in most
288 EBCDIC code pages, and also is 193 when encoded in UTF\-EBCDIC. All
289 UTF\-8 (or UTF\-EBCDIC) variant code points occupy at least two bytes when
290 encoded in UTF\-8 (or UTF\-EBCDIC); by definition, the UTF\-8 (or
291 UTF\-EBCDIC) invariant code points are exactly one byte whether encoded
292 in UTF\-8 (or UTF\-EBCDIC), or not. (By now you see why people typically
293 just say "UTF\-8" when they also mean "UTF\-EBCDIC". For the rest of this
294 document, we\*(Aqll mostly be casual about it too.)
295 In ASCII UTF\-8, the code points corresponding to the lowest 128
296 ordinal numbers (0 \- 127: the ASCII characters) are invariant.
297 In UTF\-EBCDIC, there are 160 invariant characters.
298 (If you care, the EBCDIC invariants are those characters
299 which have ASCII equivalents, plus those that correspond to
300 the C1 controls (128 \- 159 on ASCII platforms).)
301 .PP
302 A string encoded in UTF\-EBCDIC may be longer (very rarely shorter) than
303 one encoded in UTF\-8. Perl extends both UTF\-8 and UTF\-EBCDIC so that
304 they can encode code points above the Unicode maximum of U+10FFFF. Both
305 extensions are constructed to allow encoding of any code point that fits
306 in a 64\-bit word.
307 .PP
308 UTF\-EBCDIC is defined by
309 Unicode Technical Report #16 <https://www.unicode.org/reports/tr16>
310 (often referred to as just TR16).
311 It is defined based on CCSID 1047, not allowing for the differences for
312 other code pages. This allows for easy interchange of text between
313 computers running different code pages, but makes it unusable, without
314 adaptation, for Perl on those other code pages.
315 .PP
316 The reason for this unusability is that a fundamental assumption of Perl
317 is that the characters it cares about for parsing and lexical analysis
318 are the same whether or not the text is in UTF\-8. For example, Perl
319 expects the character \f(CW"["\fR to have the same representation, no matter
320 if the string containing it (or program text) is UTF\-8 encoded or not.
321 To ensure this, Perl adapts UTF\-EBCDIC to the particular code page so
322 that all characters it expects to be UTF\-8 invariant are in fact UTF\-8
323 invariant. This means that text generated on a computer running one
324 version of Perl\*(Aqs UTF\-EBCDIC has to be translated to be intelligible to
325 a computer running another.
326 .PP
327 TR16 implies a method to extend UTF\-EBCDIC to encode points up through
328 \&\f(CW\*(C`2\ **\ 31\ \-\ 1\*(C'\fR. Perl uses this method for code points up through
329 \&\f(CW\*(C`2\ **\ 30\ \-\ 1\*(C'\fR, but uses an incompatible method for larger ones, to
330 enable it to handle much larger code points than otherwise.
331 .SS "Using Encode"
332 .IX Subsection "Using Encode"
333 Starting from Perl 5.8 you can use the standard module Encode
334 to translate from EBCDIC to Latin\-1 code points.
335 Encode knows about more EBCDIC character sets than Perl can currently
336 be compiled to run on.
337 .PP
338 .Vb 1
339 \& use Encode \*(Aqfrom_to\*(Aq;
340 \&
341 \& my %ebcdic = ( 176 => \*(Aqcp37\*(Aq, 95 => \*(Aqcp1047\*(Aq, 106 => \*(Aqposix\-bc\*(Aq );
342 \&
343 \& # $x is in EBCDIC code points
344 \& from_to($x, $ebcdic{ord \*(Aq^\*(Aq}, \*(Aqlatin1\*(Aq);
345 \& # $x is ISO 8859\-1 code points
346 .Ve
347 .PP
348 and from Latin\-1 code points to EBCDIC code points
349 .PP
350 .Vb 1
351 \& use Encode \*(Aqfrom_to\*(Aq;
352 \&
353 \& my %ebcdic = ( 176 => \*(Aqcp37\*(Aq, 95 => \*(Aqcp1047\*(Aq, 106 => \*(Aqposix\-bc\*(Aq );
354 \&
355 \& # $x is ISO 8859\-1 code points
356 \& from_to($x, \*(Aqlatin1\*(Aq, $ebcdic{ord \*(Aq^\*(Aq});
357 \& # $x is in EBCDIC code points
358 .Ve
359 .PP
360 For doing I/O it is suggested that you use the autotranslating features
361 of PerlIO, see perluniintro.
362 .PP
363 Since version 5.8 Perl uses the PerlIO I/O library. This enables
364 you to use different encodings per IO channel. For example you may use
365 .PP
366 .Vb 9
367 \& use Encode;
368 \& open($f, ">:encoding(ascii)", "test.ascii");
369 \& print $f "Hello World!\en";
370 \& open($f, ">:encoding(cp37)", "test.ebcdic");
371 \& print $f "Hello World!\en";
372 \& open($f, ">:encoding(latin1)", "test.latin1");
373 \& print $f "Hello World!\en";
374 \& open($f, ">:encoding(utf8)", "test.utf8");
375 \& print $f "Hello World!\en";
376 .Ve
377 .PP
378 to get four files containing "Hello World!\en" in ASCII, CP 0037 EBCDIC,
379 ISO 8859\-1 (Latin\-1) (in this example identical to ASCII since only ASCII
380 characters were printed), and
381 UTF\-EBCDIC (in this example identical to normal EBCDIC since only characters
382 that don\*(Aqt differ between EBCDIC and UTF\-EBCDIC were printed). See the
383 documentation of Encode::PerlIO for details.
384 .PP
385 As the PerlIO layer uses raw IO (bytes) internally, all this totally
386 ignores things like the type of your filesystem (ASCII or EBCDIC).
387 .SH "SINGLE OCTET TABLES"
388 .IX Header "SINGLE OCTET TABLES"
389 The following tables list the ASCII and Latin 1 ordered sets including
390 the subsets: C0 controls (0..31), ASCII graphics (32..7e), delete (7f),
391 C1 controls (80..9f), and Latin\-1 (a.k.a. ISO 8859\-1) (a0..ff). In the
392 table names of the Latin 1
393 extensions to ASCII have been labelled with character names roughly
394 corresponding to \fIThe Unicode Standard, Version 6.1\fR albeit with
395 substitutions such as \f(CW\*(C`s/LATIN//\*(C'\fR and \f(CW\*(C`s/VULGAR//\*(C'\fR in all cases;
396 \&\f(CW\*(C`s/CAPITAL\ LETTER//\*(C'\fR in some cases; and
397 \&\f(CW\*(C`s/SMALL\ LETTER\ ([A\-Z])/\el$1/\*(C'\fR in some other
398 cases. Controls are listed using their Unicode 6.2 abbreviations.
399 The differences between the 0037 and 1047 sets are
400 flagged with \f(CW\*(C`**\*(C'\fR. The differences between the 1047 and POSIX\-BC sets
401 are flagged with \f(CW\*(C`##.\*(C'\fR All \f(CWord()\fR numbers listed are decimal. If you
402 would rather see this table listing octal values, then run the table
403 (that is, the pod source text of this document, since this recipe may not
404 work with a pod2_other_format translation) through:
405 .IP "recipe 0" 4
406 .IX Item "recipe 0"
407 .PP
408 .Vb 3
409 \& perl \-ne \*(Aqif(/(.{29})(\ed+)\es+(\ed+)\es+(\ed+)\es+(\ed+)/)\*(Aq \e
410 \& \-e \*(Aq{printf("%s%\-5.03o%\-5.03o%\-5.03o%.03o\en",$1,$2,$3,$4,$5)}\*(Aq \e
411 \& perlebcdic.pod
412 .Ve
413 .PP
414 If you want to retain the UTF\-x code points then in script form you
415 might want to write:
416 .IP "recipe 1" 4
417 .IX Item "recipe 1"
418 .PP
419 .Vb 10
420 \& open(FH,"<perlebcdic.pod") or die "Could not open perlebcdic.pod: $!";
421 \& while (<FH>) {
422 \& if (/(.{29})(\ed+)\es+(\ed+)\es+(\ed+)\es+(\ed+)\es+(\ed+)\e.?(\ed*)
423 \& \es+(\ed+)\e.?(\ed*)/x)
424 \& {
425 \& if ($7 ne \*(Aq\*(Aq && $9 ne \*(Aq\*(Aq) {
426 \& printf(
427 \& "%s%\-5.03o%\-5.03o%\-5.03o%\-5.03o%\-3o.%\-5o%\-3o.%.03o\en",
428 \& $1,$2,$3,$4,$5,$6,$7,$8,$9);
429 \& }
430 \& elsif ($7 ne \*(Aq\*(Aq) {
431 \& printf("%s%\-5.03o%\-5.03o%\-5.03o%\-5.03o%\-3o.%\-5o%.03o\en",
432 \& $1,$2,$3,$4,$5,$6,$7,$8);
433 \& }
434 \& else {
435 \& printf("%s%\-5.03o%\-5.03o%\-5.03o%\-5.03o%\-5.03o%.03o\en",
436 \& $1,$2,$3,$4,$5,$6,$8);
437 \& }
438 \& }
439 \& }
440 .Ve
441 .PP
442 If you would rather see this table listing hexadecimal values then
443 run the table through:
444 .IP "recipe 2" 4
445 .IX Item "recipe 2"
446 .PP
447 .Vb 3
448 \& perl \-ne \*(Aqif(/(.{29})(\ed+)\es+(\ed+)\es+(\ed+)\es+(\ed+)/)\*(Aq \e
449 \& \-e \*(Aq{printf("%s%\-5.02X%\-5.02X%\-5.02X%.02X\en",$1,$2,$3,$4,$5)}\*(Aq \e
450 \& perlebcdic.pod
451 .Ve
452 .PP
453 Or, in order to retain the UTF\-x code points in hexadecimal:
454 .IP "recipe 3" 4
455 .IX Item "recipe 3"
456 .PP
457 .Vb 10
458 \& open(FH,"<perlebcdic.pod") or die "Could not open perlebcdic.pod: $!";
459 \& while (<FH>) {
460 \& if (/(.{29})(\ed+)\es+(\ed+)\es+(\ed+)\es+(\ed+)\es+(\ed+)\e.?(\ed*)
461 \& \es+(\ed+)\e.?(\ed*)/x)
462 \& {
463 \& if ($7 ne \*(Aq\*(Aq && $9 ne \*(Aq\*(Aq) {
464 \& printf(
465 \& "%s%\-5.02X%\-5.02X%\-5.02X%\-5.02X%\-2X.%\-6.02X%02X.%02X\en",
466 \& $1,$2,$3,$4,$5,$6,$7,$8,$9);
467 \& }
468 \& elsif ($7 ne \*(Aq\*(Aq) {
469 \& printf("%s%\-5.02X%\-5.02X%\-5.02X%\-5.02X%\-2X.%\-6.02X%02X\en",
470 \& $1,$2,$3,$4,$5,$6,$7,$8);
471 \& }
472 \& else {
473 \& printf("%s%\-5.02X%\-5.02X%\-5.02X%\-5.02X%\-5.02X%02X\en",
474 \& $1,$2,$3,$4,$5,$6,$8);
475 \& }
476 \& }
477 \& }
478 \&
479 \&
480 \& ISO
481 \& 8859\-1 POS\- CCSID
482 \& CCSID CCSID CCSID IX\- 1047
483 \& chr 0819 0037 1047 BC UTF\-8 UTF\-EBCDIC
484 \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
485 \& <NUL> 0 0 0 0 0 0
486 \& <SOH> 1 1 1 1 1 1
487 \& <STX> 2 2 2 2 2 2
488 \& <ETX> 3 3 3 3 3 3
489 \& <EOT> 4 55 55 55 4 55
490 \& <ENQ> 5 45 45 45 5 45
491 \& <ACK> 6 46 46 46 6 46
492 \& <BEL> 7 47 47 47 7 47
493 \& <BS> 8 22 22 22 8 22
494 \& <HT> 9 5 5 5 9 5
495 \& <LF> 10 37 21 21 10 21 **
496 \& <VT> 11 11 11 11 11 11
497 \& <FF> 12 12 12 12 12 12
498 \& <CR> 13 13 13 13 13 13
499 \& <SO> 14 14 14 14 14 14
500 \& <SI> 15 15 15 15 15 15
501 \& <DLE> 16 16 16 16 16 16
502 \& <DC1> 17 17 17 17 17 17
503 \& <DC2> 18 18 18 18 18 18
504 \& <DC3> 19 19 19 19 19 19
505 \& <DC4> 20 60 60 60 20 60
506 \& <NAK> 21 61 61 61 21 61
507 \& <SYN> 22 50 50 50 22 50
508 \& <ETB> 23 38 38 38 23 38
509 \& <CAN> 24 24 24 24 24 24
510 \& <EOM> 25 25 25 25 25 25
511 \& <SUB> 26 63 63 63 26 63
512 \& <ESC> 27 39 39 39 27 39
513 \& <FS> 28 28 28 28 28 28
514 \& <GS> 29 29 29 29 29 29
515 \& <RS> 30 30 30 30 30 30
516 \& <US> 31 31 31 31 31 31
517 \& <SPACE> 32 64 64 64 32 64
518 \& ! 33 90 90 90 33 90
519 \& " 34 127 127 127 34 127
520 \& # 35 123 123 123 35 123
521 \& $ 36 91 91 91 36 91
522 \& % 37 108 108 108 37 108
523 \& & 38 80 80 80 38 80
524 \& \*(Aq 39 125 125 125 39 125
525 \& ( 40 77 77 77 40 77
526 \& ) 41 93 93 93 41 93
527 \& * 42 92 92 92 42 92
528 \& + 43 78 78 78 43 78
529 \& , 44 107 107 107 44 107
530 \& \- 45 96 96 96 45 96
531 \& . 46 75 75 75 46 75
532 \& / 47 97 97 97 47 97
533 \& 0 48 240 240 240 48 240
534 \& 1 49 241 241 241 49 241
535 \& 2 50 242 242 242 50 242
536 \& 3 51 243 243 243 51 243
537 \& 4 52 244 244 244 52 244
538 \& 5 53 245 245 245 53 245
539 \& 6 54 246 246 246 54 246
540 \& 7 55 247 247 247 55 247
541 \& 8 56 248 248 248 56 248
542 \& 9 57 249 249 249 57 249
543 \& : 58 122 122 122 58 122
544 \& ; 59 94 94 94 59 94
545 \& < 60 76 76 76 60 76
546 \& = 61 126 126 126 61 126
547 \& > 62 110 110 110 62 110
548 \& ? 63 111 111 111 63 111
549 \& @ 64 124 124 124 64 124
550 \& A 65 193 193 193 65 193
551 \& B 66 194 194 194 66 194
552 \& C 67 195 195 195 67 195
553 \& D 68 196 196 196 68 196
554 \& E 69 197 197 197 69 197
555 \& F 70 198 198 198 70 198
556 \& G 71 199 199 199 71 199
557 \& H 72 200 200 200 72 200
558 \& I 73 201 201 201 73 201
559 \& J 74 209 209 209 74 209
560 \& K 75 210 210 210 75 210
561 \& L 76 211 211 211 76 211
562 \& M 77 212 212 212 77 212
563 \& N 78 213 213 213 78 213
564 \& O 79 214 214 214 79 214
565 \& P 80 215 215 215 80 215
566 \& Q 81 216 216 216 81 216
567 \& R 82 217 217 217 82 217
568 \& S 83 226 226 226 83 226
569 \& T 84 227 227 227 84 227
570 \& U 85 228 228 228 85 228
571 \& V 86 229 229 229 86 229
572 \& W 87 230 230 230 87 230
573 \& X 88 231 231 231 88 231
574 \& Y 89 232 232 232 89 232
575 \& Z 90 233 233 233 90 233
576 \& [ 91 186 173 187 91 173 ** ##
577 \& \e 92 224 224 188 92 224 ##
578 \& ] 93 187 189 189 93 189 **
579 \& ^ 94 176 95 106 94 95 ** ##
580 \& _ 95 109 109 109 95 109
581 \& \` 96 121 121 74 96 121 ##
582 \& a 97 129 129 129 97 129
583 \& b 98 130 130 130 98 130
584 \& c 99 131 131 131 99 131
585 \& d 100 132 132 132 100 132
586 \& e 101 133 133 133 101 133
587 \& f 102 134 134 134 102 134
588 \& g 103 135 135 135 103 135
589 \& h 104 136 136 136 104 136
590 \& i 105 137 137 137 105 137
591 \& j 106 145 145 145 106 145
592 \& k 107 146 146 146 107 146
593 \& l 108 147 147 147 108 147
594 \& m 109 148 148 148 109 148
595 \& n 110 149 149 149 110 149
596 \& o 111 150 150 150 111 150
597 \& p 112 151 151 151 112 151
598 \& q 113 152 152 152 113 152
599 \& r 114 153 153 153 114 153
600 \& s 115 162 162 162 115 162
601 \& t 116 163 163 163 116 163
602 \& u 117 164 164 164 117 164
603 \& v 118 165 165 165 118 165
604 \& w 119 166 166 166 119 166
605 \& x 120 167 167 167 120 167
606 \& y 121 168 168 168 121 168
607 \& z 122 169 169 169 122 169
608 \& { 123 192 192 251 123 192 ##
609 \& | 124 79 79 79 124 79
610 \& } 125 208 208 253 125 208 ##
611 \& ~ 126 161 161 255 126 161 ##
612 \& <DEL> 127 7 7 7 127 7
613 \& <PAD> 128 32 32 32 194.128 32
614 \& <HOP> 129 33 33 33 194.129 33
615 \& <BPH> 130 34 34 34 194.130 34
616 \& <NBH> 131 35 35 35 194.131 35
617 \& <IND> 132 36 36 36 194.132 36
618 \& <NEL> 133 21 37 37 194.133 37 **
619 \& <SSA> 134 6 6 6 194.134 6
620 \& <ESA> 135 23 23 23 194.135 23
621 \& <HTS> 136 40 40 40 194.136 40
622 \& <HTJ> 137 41 41 41 194.137 41
623 \& <VTS> 138 42 42 42 194.138 42
624 \& <PLD> 139 43 43 43 194.139 43
625 \& <PLU> 140 44 44 44 194.140 44
626 \& <RI> 141 9 9 9 194.141 9
627 \& <SS2> 142 10 10 10 194.142 10
628 \& <SS3> 143 27 27 27 194.143 27
629 \& <DCS> 144 48 48 48 194.144 48
630 \& <PU1> 145 49 49 49 194.145 49
631 \& <PU2> 146 26 26 26 194.146 26
632 \& <STS> 147 51 51 51 194.147 51
633 \& <CCH> 148 52 52 52 194.148 52
634 \& <MW> 149 53 53 53 194.149 53
635 \& <SPA> 150 54 54 54 194.150 54
636 \& <EPA> 151 8 8 8 194.151 8
637 \& <SOS> 152 56 56 56 194.152 56
638 \& <SGC> 153 57 57 57 194.153 57
639 \& <SCI> 154 58 58 58 194.154 58
640 \& <CSI> 155 59 59 59 194.155 59
641 \& <ST> 156 4 4 4 194.156 4
642 \& <OSC> 157 20 20 20 194.157 20
643 \& <PM> 158 62 62 62 194.158 62
644 \& <APC> 159 255 255 95 194.159 255 ##
645 \& <NON\-BREAKING SPACE> 160 65 65 65 194.160 128.65
646 \& <INVERTED "!" > 161 170 170 170 194.161 128.66
647 \& <CENT SIGN> 162 74 74 176 194.162 128.67 ##
648 \& <POUND SIGN> 163 177 177 177 194.163 128.68
649 \& <CURRENCY SIGN> 164 159 159 159 194.164 128.69
650 \& <YEN SIGN> 165 178 178 178 194.165 128.70
651 \& <BROKEN BAR> 166 106 106 208 194.166 128.71 ##
652 \& <SECTION SIGN> 167 181 181 181 194.167 128.72
653 \& <DIAERESIS> 168 189 187 121 194.168 128.73 ** ##
654 \& <COPYRIGHT SIGN> 169 180 180 180 194.169 128.74
655 \& <FEMININE ORDINAL> 170 154 154 154 194.170 128.81
656 \& <LEFT POINTING GUILLEMET> 171 138 138 138 194.171 128.82
657 \& <NOT SIGN> 172 95 176 186 194.172 128.83 ** ##
658 \& <SOFT HYPHEN> 173 202 202 202 194.173 128.84
659 \& <REGISTERED TRADE MARK> 174 175 175 175 194.174 128.85
660 \& <MACRON> 175 188 188 161 194.175 128.86 ##
661 \& <DEGREE SIGN> 176 144 144 144 194.176 128.87
662 \& <PLUS\-OR\-MINUS SIGN> 177 143 143 143 194.177 128.88
663 \& <SUPERSCRIPT TWO> 178 234 234 234 194.178 128.89
664 \& <SUPERSCRIPT THREE> 179 250 250 250 194.179 128.98
665 \& <ACUTE ACCENT> 180 190 190 190 194.180 128.99
666 \& <MICRO SIGN> 181 160 160 160 194.181 128.100
667 \& <PARAGRAPH SIGN> 182 182 182 182 194.182 128.101
668 \& <MIDDLE DOT> 183 179 179 179 194.183 128.102
669 \& <CEDILLA> 184 157 157 157 194.184 128.103
670 \& <SUPERSCRIPT ONE> 185 218 218 218 194.185 128.104
671 \& <MASC. ORDINAL INDICATOR> 186 155 155 155 194.186 128.105
672 \& <RIGHT POINTING GUILLEMET> 187 139 139 139 194.187 128.106
673 \& <FRACTION ONE QUARTER> 188 183 183 183 194.188 128.112
674 \& <FRACTION ONE HALF> 189 184 184 184 194.189 128.113
675 \& <FRACTION THREE QUARTERS> 190 185 185 185 194.190 128.114
676 \& <INVERTED QUESTION MARK> 191 171 171 171 194.191 128.115
677 \& <A WITH GRAVE> 192 100 100 100 195.128 138.65
678 \& <A WITH ACUTE> 193 101 101 101 195.129 138.66
679 \& <A WITH CIRCUMFLEX> 194 98 98 98 195.130 138.67
680 \& <A WITH TILDE> 195 102 102 102 195.131 138.68
681 \& <A WITH DIAERESIS> 196 99 99 99 195.132 138.69
682 \& <A WITH RING ABOVE> 197 103 103 103 195.133 138.70
683 \& <CAPITAL LIGATURE AE> 198 158 158 158 195.134 138.71
684 \& <C WITH CEDILLA> 199 104 104 104 195.135 138.72
685 \& <E WITH GRAVE> 200 116 116 116 195.136 138.73
686 \& <E WITH ACUTE> 201 113 113 113 195.137 138.74
687 \& <E WITH CIRCUMFLEX> 202 114 114 114 195.138 138.81
688 \& <E WITH DIAERESIS> 203 115 115 115 195.139 138.82
689 \& <I WITH GRAVE> 204 120 120 120 195.140 138.83
690 \& <I WITH ACUTE> 205 117 117 117 195.141 138.84
691 \& <I WITH CIRCUMFLEX> 206 118 118 118 195.142 138.85
692 \& <I WITH DIAERESIS> 207 119 119 119 195.143 138.86
693 \& <CAPITAL LETTER ETH> 208 172 172 172 195.144 138.87
694 \& <N WITH TILDE> 209 105 105 105 195.145 138.88
695 \& <O WITH GRAVE> 210 237 237 237 195.146 138.89
696 \& <O WITH ACUTE> 211 238 238 238 195.147 138.98
697 \& <O WITH CIRCUMFLEX> 212 235 235 235 195.148 138.99
698 \& <O WITH TILDE> 213 239 239 239 195.149 138.100
699 \& <O WITH DIAERESIS> 214 236 236 236 195.150 138.101
700 \& <MULTIPLICATION SIGN> 215 191 191 191 195.151 138.102
701 \& <O WITH STROKE> 216 128 128 128 195.152 138.103
702 \& <U WITH GRAVE> 217 253 253 224 195.153 138.104 ##
703 \& <U WITH ACUTE> 218 254 254 254 195.154 138.105
704 \& <U WITH CIRCUMFLEX> 219 251 251 221 195.155 138.106 ##
705 \& <U WITH DIAERESIS> 220 252 252 252 195.156 138.112
706 \& <Y WITH ACUTE> 221 173 186 173 195.157 138.113 ** ##
707 \& <CAPITAL LETTER THORN> 222 174 174 174 195.158 138.114
708 \& <SMALL LETTER SHARP S> 223 89 89 89 195.159 138.115
709 \& <a WITH GRAVE> 224 68 68 68 195.160 139.65
710 \& <a WITH ACUTE> 225 69 69 69 195.161 139.66
711 \& <a WITH CIRCUMFLEX> 226 66 66 66 195.162 139.67
712 \& <a WITH TILDE> 227 70 70 70 195.163 139.68
713 \& <a WITH DIAERESIS> 228 67 67 67 195.164 139.69
714 \& <a WITH RING ABOVE> 229 71 71 71 195.165 139.70
715 \& <SMALL LIGATURE ae> 230 156 156 156 195.166 139.71
716 \& <c WITH CEDILLA> 231 72 72 72 195.167 139.72
717 \& <e WITH GRAVE> 232 84 84 84 195.168 139.73
718 \& <e WITH ACUTE> 233 81 81 81 195.169 139.74
719 \& <e WITH CIRCUMFLEX> 234 82 82 82 195.170 139.81
720 \& <e WITH DIAERESIS> 235 83 83 83 195.171 139.82
721 \& <i WITH GRAVE> 236 88 88 88 195.172 139.83
722 \& <i WITH ACUTE> 237 85 85 85 195.173 139.84
723 \& <i WITH CIRCUMFLEX> 238 86 86 86 195.174 139.85
724 \& <i WITH DIAERESIS> 239 87 87 87 195.175 139.86
725 \& <SMALL LETTER eth> 240 140 140 140 195.176 139.87
726 \& <n WITH TILDE> 241 73 73 73 195.177 139.88
727 \& <o WITH GRAVE> 242 205 205 205 195.178 139.89
728 \& <o WITH ACUTE> 243 206 206 206 195.179 139.98
729 \& <o WITH CIRCUMFLEX> 244 203 203 203 195.180 139.99
730 \& <o WITH TILDE> 245 207 207 207 195.181 139.100
731 \& <o WITH DIAERESIS> 246 204 204 204 195.182 139.101
732 \& <DIVISION SIGN> 247 225 225 225 195.183 139.102
733 \& <o WITH STROKE> 248 112 112 112 195.184 139.103
734 \& <u WITH GRAVE> 249 221 221 192 195.185 139.104 ##
735 \& <u WITH ACUTE> 250 222 222 222 195.186 139.105
736 \& <u WITH CIRCUMFLEX> 251 219 219 219 195.187 139.106
737 \& <u WITH DIAERESIS> 252 220 220 220 195.188 139.112
738 \& <y WITH ACUTE> 253 141 141 141 195.189 139.113
739 \& <SMALL LETTER thorn> 254 142 142 142 195.190 139.114
740 \& <y WITH DIAERESIS> 255 223 223 223 195.191 139.115
741 .Ve
742 .PP
743 If you would rather see the above table in CCSID 0037 order rather than
744 ASCII + Latin\-1 order then run the table through:
745 .IP "recipe 4" 4
746 .IX Item "recipe 4"
747 .PP
748 .Vb 6
749 \& perl \e
750 \& \-ne \*(Aqif(/.{29}\ed{1,3}\es{2,4}\ed{1,3}\es{2,4}\ed{1,3}\es{2,4}\ed{1,3}/)\*(Aq\e
751 \& \-e \*(Aq{push(@l,$_)}\*(Aq \e
752 \& \-e \*(AqEND{print map{$_\->[0]}\*(Aq \e
753 \& \-e \*(Aq sort{$a\->[1] <=> $b\->[1]}\*(Aq \e
754 \& \-e \*(Aq map{[$_,substr($_,34,3)]}@l;}\*(Aq perlebcdic.pod
755 .Ve
756 .PP
757 If you would rather see it in CCSID 1047 order then change the number
758 34 in the last line to 39, like this:
759 .IP "recipe 5" 4
760 .IX Item "recipe 5"
761 .PP
762 .Vb 6
763 \& perl \e
764 \& \-ne \*(Aqif(/.{29}\ed{1,3}\es{2,4}\ed{1,3}\es{2,4}\ed{1,3}\es{2,4}\ed{1,3}/)\*(Aq\e
765 \& \-e \*(Aq{push(@l,$_)}\*(Aq \e
766 \& \-e \*(AqEND{print map{$_\->[0]}\*(Aq \e
767 \& \-e \*(Aq sort{$a\->[1] <=> $b\->[1]}\*(Aq \e
768 \& \-e \*(Aq map{[$_,substr($_,39,3)]}@l;}\*(Aq perlebcdic.pod
769 .Ve
770 .PP
771 If you would rather see it in POSIX\-BC order then change the number
772 34 in the last line to 44, like this:
773 .IP "recipe 6" 4
774 .IX Item "recipe 6"
775 .PP
776 .Vb 6
777 \& perl \e
778 \& \-ne \*(Aqif(/.{29}\ed{1,3}\es{2,4}\ed{1,3}\es{2,4}\ed{1,3}\es{2,4}\ed{1,3}/)\*(Aq\e
779 \& \-e \*(Aq{push(@l,$_)}\*(Aq \e
780 \& \-e \*(AqEND{print map{$_\->[0]}\*(Aq \e
781 \& \-e \*(Aq sort{$a\->[1] <=> $b\->[1]}\*(Aq \e
782 \& \-e \*(Aq map{[$_,substr($_,44,3)]}@l;}\*(Aq perlebcdic.pod
783 .Ve
784 .SS "Table in hex, sorted in 1047 order"
785 .IX Subsection "Table in hex, sorted in 1047 order"
786 Since this document was first written, the convention has become more
787 and more to use hexadecimal notation for code points. To do this with
788 the recipes and to also sort is a multi\-step process, so here, for
789 convenience, is the table from above, re\-sorted to be in Code Page 1047
790 order, and using hex notation.
791 .PP
792 .Vb 10
793 \& ISO
794 \& 8859\-1 POS\- CCSID
795 \& CCSID CCSID CCSID IX\- 1047
796 \& chr 0819 0037 1047 BC UTF\-8 UTF\-EBCDIC
797 \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
798 \& <NUL> 00 00 00 00 00 00
799 \& <SOH> 01 01 01 01 01 01
800 \& <STX> 02 02 02 02 02 02
801 \& <ETX> 03 03 03 03 03 03
802 \& <ST> 9C 04 04 04 C2.9C 04
803 \& <HT> 09 05 05 05 09 05
804 \& <SSA> 86 06 06 06 C2.86 06
805 \& <DEL> 7F 07 07 07 7F 07
806 \& <EPA> 97 08 08 08 C2.97 08
807 \& <RI> 8D 09 09 09 C2.8D 09
808 \& <SS2> 8E 0A 0A 0A C2.8E 0A
809 \& <VT> 0B 0B 0B 0B 0B 0B
810 \& <FF> 0C 0C 0C 0C 0C 0C
811 \& <CR> 0D 0D 0D 0D 0D 0D
812 \& <SO> 0E 0E 0E 0E 0E 0E
813 \& <SI> 0F 0F 0F 0F 0F 0F
814 \& <DLE> 10 10 10 10 10 10
815 \& <DC1> 11 11 11 11 11 11
816 \& <DC2> 12 12 12 12 12 12
817 \& <DC3> 13 13 13 13 13 13
818 \& <OSC> 9D 14 14 14 C2.9D 14
819 \& <LF> 0A 25 15 15 0A 15 **
820 \& <BS> 08 16 16 16 08 16
821 \& <ESA> 87 17 17 17 C2.87 17
822 \& <CAN> 18 18 18 18 18 18
823 \& <EOM> 19 19 19 19 19 19
824 \& <PU2> 92 1A 1A 1A C2.92 1A
825 \& <SS3> 8F 1B 1B 1B C2.8F 1B
826 \& <FS> 1C 1C 1C 1C 1C 1C
827 \& <GS> 1D 1D 1D 1D 1D 1D
828 \& <RS> 1E 1E 1E 1E 1E 1E
829 \& <US> 1F 1F 1F 1F 1F 1F
830 \& <PAD> 80 20 20 20 C2.80 20
831 \& <HOP> 81 21 21 21 C2.81 21
832 \& <BPH> 82 22 22 22 C2.82 22
833 \& <NBH> 83 23 23 23 C2.83 23
834 \& <IND> 84 24 24 24 C2.84 24
835 \& <NEL> 85 15 25 25 C2.85 25 **
836 \& <ETB> 17 26 26 26 17 26
837 \& <ESC> 1B 27 27 27 1B 27
838 \& <HTS> 88 28 28 28 C2.88 28
839 \& <HTJ> 89 29 29 29 C2.89 29
840 \& <VTS> 8A 2A 2A 2A C2.8A 2A
841 \& <PLD> 8B 2B 2B 2B C2.8B 2B
842 \& <PLU> 8C 2C 2C 2C C2.8C 2C
843 \& <ENQ> 05 2D 2D 2D 05 2D
844 \& <ACK> 06 2E 2E 2E 06 2E
845 \& <BEL> 07 2F 2F 2F 07 2F
846 \& <DCS> 90 30 30 30 C2.90 30
847 \& <PU1> 91 31 31 31 C2.91 31
848 \& <SYN> 16 32 32 32 16 32
849 \& <STS> 93 33 33 33 C2.93 33
850 \& <CCH> 94 34 34 34 C2.94 34
851 \& <MW> 95 35 35 35 C2.95 35
852 \& <SPA> 96 36 36 36 C2.96 36
853 \& <EOT> 04 37 37 37 04 37
854 \& <SOS> 98 38 38 38 C2.98 38
855 \& <SGC> 99 39 39 39 C2.99 39
856 \& <SCI> 9A 3A 3A 3A C2.9A 3A
857 \& <CSI> 9B 3B 3B 3B C2.9B 3B
858 \& <DC4> 14 3C 3C 3C 14 3C
859 \& <NAK> 15 3D 3D 3D 15 3D
860 \& <PM> 9E 3E 3E 3E C2.9E 3E
861 \& <SUB> 1A 3F 3F 3F 1A 3F
862 \& <SPACE> 20 40 40 40 20 40
863 \& <NON\-BREAKING SPACE> A0 41 41 41 C2.A0 80.41
864 \& <a WITH CIRCUMFLEX> E2 42 42 42 C3.A2 8B.43
865 \& <a WITH DIAERESIS> E4 43 43 43 C3.A4 8B.45
866 \& <a WITH GRAVE> E0 44 44 44 C3.A0 8B.41
867 \& <a WITH ACUTE> E1 45 45 45 C3.A1 8B.42
868 \& <a WITH TILDE> E3 46 46 46 C3.A3 8B.44
869 \& <a WITH RING ABOVE> E5 47 47 47 C3.A5 8B.46
870 \& <c WITH CEDILLA> E7 48 48 48 C3.A7 8B.48
871 \& <n WITH TILDE> F1 49 49 49 C3.B1 8B.58
872 \& <CENT SIGN> A2 4A 4A B0 C2.A2 80.43 ##
873 \& . 2E 4B 4B 4B 2E 4B
874 \& < 3C 4C 4C 4C 3C 4C
875 \& ( 28 4D 4D 4D 28 4D
876 \& + 2B 4E 4E 4E 2B 4E
877 \& | 7C 4F 4F 4F 7C 4F
878 \& & 26 50 50 50 26 50
879 \& <e WITH ACUTE> E9 51 51 51 C3.A9 8B.4A
880 \& <e WITH CIRCUMFLEX> EA 52 52 52 C3.AA 8B.51
881 \& <e WITH DIAERESIS> EB 53 53 53 C3.AB 8B.52
882 \& <e WITH GRAVE> E8 54 54 54 C3.A8 8B.49
883 \& <i WITH ACUTE> ED 55 55 55 C3.AD 8B.54
884 \& <i WITH CIRCUMFLEX> EE 56 56 56 C3.AE 8B.55
885 \& <i WITH DIAERESIS> EF 57 57 57 C3.AF 8B.56
886 \& <i WITH GRAVE> EC 58 58 58 C3.AC 8B.53
887 \& <SMALL LETTER SHARP S> DF 59 59 59 C3.9F 8A.73
888 \& ! 21 5A 5A 5A 21 5A
889 \& $ 24 5B 5B 5B 24 5B
890 \& * 2A 5C 5C 5C 2A 5C
891 \& ) 29 5D 5D 5D 29 5D
892 \& ; 3B 5E 5E 5E 3B 5E
893 \& ^ 5E B0 5F 6A 5E 5F ** ##
894 \& \- 2D 60 60 60 2D 60
895 \& / 2F 61 61 61 2F 61
896 \& <A WITH CIRCUMFLEX> C2 62 62 62 C3.82 8A.43
897 \& <A WITH DIAERESIS> C4 63 63 63 C3.84 8A.45
898 \& <A WITH GRAVE> C0 64 64 64 C3.80 8A.41
899 \& <A WITH ACUTE> C1 65 65 65 C3.81 8A.42
900 \& <A WITH TILDE> C3 66 66 66 C3.83 8A.44
901 \& <A WITH RING ABOVE> C5 67 67 67 C3.85 8A.46
902 \& <C WITH CEDILLA> C7 68 68 68 C3.87 8A.48
903 \& <N WITH TILDE> D1 69 69 69 C3.91 8A.58
904 \& <BROKEN BAR> A6 6A 6A D0 C2.A6 80.47 ##
905 \& , 2C 6B 6B 6B 2C 6B
906 \& % 25 6C 6C 6C 25 6C
907 \& _ 5F 6D 6D 6D 5F 6D
908 \& > 3E 6E 6E 6E 3E 6E
909 \& ? 3F 6F 6F 6F 3F 6F
910 \& <o WITH STROKE> F8 70 70 70 C3.B8 8B.67
911 \& <E WITH ACUTE> C9 71 71 71 C3.89 8A.4A
912 \& <E WITH CIRCUMFLEX> CA 72 72 72 C3.8A 8A.51
913 \& <E WITH DIAERESIS> CB 73 73 73 C3.8B 8A.52
914 \& <E WITH GRAVE> C8 74 74 74 C3.88 8A.49
915 \& <I WITH ACUTE> CD 75 75 75 C3.8D 8A.54
916 \& <I WITH CIRCUMFLEX> CE 76 76 76 C3.8E 8A.55
917 \& <I WITH DIAERESIS> CF 77 77 77 C3.8F 8A.56
918 \& <I WITH GRAVE> CC 78 78 78 C3.8C 8A.53
919 \& \` 60 79 79 4A 60 79 ##
920 \& : 3A 7A 7A 7A 3A 7A
921 \& # 23 7B 7B 7B 23 7B
922 \& @ 40 7C 7C 7C 40 7C
923 \& \*(Aq 27 7D 7D 7D 27 7D
924 \& = 3D 7E 7E 7E 3D 7E
925 \& " 22 7F 7F 7F 22 7F
926 \& <O WITH STROKE> D8 80 80 80 C3.98 8A.67
927 \& a 61 81 81 81 61 81
928 \& b 62 82 82 82 62 82
929 \& c 63 83 83 83 63 83
930 \& d 64 84 84 84 64 84
931 \& e 65 85 85 85 65 85
932 \& f 66 86 86 86 66 86
933 \& g 67 87 87 87 67 87
934 \& h 68 88 88 88 68 88
935 \& i 69 89 89 89 69 89
936 \& <LEFT POINTING GUILLEMET> AB 8A 8A 8A C2.AB 80.52
937 \& <RIGHT POINTING GUILLEMET> BB 8B 8B 8B C2.BB 80.6A
938 \& <SMALL LETTER eth> F0 8C 8C 8C C3.B0 8B.57
939 \& <y WITH ACUTE> FD 8D 8D 8D C3.BD 8B.71
940 \& <SMALL LETTER thorn> FE 8E 8E 8E C3.BE 8B.72
941 \& <PLUS\-OR\-MINUS SIGN> B1 8F 8F 8F C2.B1 80.58
942 \& <DEGREE SIGN> B0 90 90 90 C2.B0 80.57
943 \& j 6A 91 91 91 6A 91
944 \& k 6B 92 92 92 6B 92
945 \& l 6C 93 93 93 6C 93
946 \& m 6D 94 94 94 6D 94
947 \& n 6E 95 95 95 6E 95
948 \& o 6F 96 96 96 6F 96
949 \& p 70 97 97 97 70 97
950 \& q 71 98 98 98 71 98
951 \& r 72 99 99 99 72 99
952 \& <FEMININE ORDINAL> AA 9A 9A 9A C2.AA 80.51
953 \& <MASC. ORDINAL INDICATOR> BA 9B 9B 9B C2.BA 80.69
954 \& <SMALL LIGATURE ae> E6 9C 9C 9C C3.A6 8B.47
955 \& <CEDILLA> B8 9D 9D 9D C2.B8 80.67
956 \& <CAPITAL LIGATURE AE> C6 9E 9E 9E C3.86 8A.47
957 \& <CURRENCY SIGN> A4 9F 9F 9F C2.A4 80.45
958 \& <MICRO SIGN> B5 A0 A0 A0 C2.B5 80.64
959 \& ~ 7E A1 A1 FF 7E A1 ##
960 \& s 73 A2 A2 A2 73 A2
961 \& t 74 A3 A3 A3 74 A3
962 \& u 75 A4 A4 A4 75 A4
963 \& v 76 A5 A5 A5 76 A5
964 \& w 77 A6 A6 A6 77 A6
965 \& x 78 A7 A7 A7 78 A7
966 \& y 79 A8 A8 A8 79 A8
967 \& z 7A A9 A9 A9 7A A9
968 \& <INVERTED "!" > A1 AA AA AA C2.A1 80.42
969 \& <INVERTED QUESTION MARK> BF AB AB AB C2.BF 80.73
970 \& <CAPITAL LETTER ETH> D0 AC AC AC C3.90 8A.57
971 \& [ 5B BA AD BB 5B AD ** ##
972 \& <CAPITAL LETTER THORN> DE AE AE AE C3.9E 8A.72
973 \& <REGISTERED TRADE MARK> AE AF AF AF C2.AE 80.55
974 \& <NOT SIGN> AC 5F B0 BA C2.AC 80.53 ** ##
975 \& <POUND SIGN> A3 B1 B1 B1 C2.A3 80.44
976 \& <YEN SIGN> A5 B2 B2 B2 C2.A5 80.46
977 \& <MIDDLE DOT> B7 B3 B3 B3 C2.B7 80.66
978 \& <COPYRIGHT SIGN> A9 B4 B4 B4 C2.A9 80.4A
979 \& <SECTION SIGN> A7 B5 B5 B5 C2.A7 80.48
980 \& <PARAGRAPH SIGN> B6 B6 B6 B6 C2.B6 80.65
981 \& <FRACTION ONE QUARTER> BC B7 B7 B7 C2.BC 80.70
982 \& <FRACTION ONE HALF> BD B8 B8 B8 C2.BD 80.71
983 \& <FRACTION THREE QUARTERS> BE B9 B9 B9 C2.BE 80.72
984 \& <Y WITH ACUTE> DD AD BA AD C3.9D 8A.71 ** ##
985 \& <DIAERESIS> A8 BD BB 79 C2.A8 80.49 ** ##
986 \& <MACRON> AF BC BC A1 C2.AF 80.56 ##
987 \& ] 5D BB BD BD 5D BD **
988 \& <ACUTE ACCENT> B4 BE BE BE C2.B4 80.63
989 \& <MULTIPLICATION SIGN> D7 BF BF BF C3.97 8A.66
990 \& { 7B C0 C0 FB 7B C0 ##
991 \& A 41 C1 C1 C1 41 C1
992 \& B 42 C2 C2 C2 42 C2
993 \& C 43 C3 C3 C3 43 C3
994 \& D 44 C4 C4 C4 44 C4
995 \& E 45 C5 C5 C5 45 C5
996 \& F 46 C6 C6 C6 46 C6
997 \& G 47 C7 C7 C7 47 C7
998 \& H 48 C8 C8 C8 48 C8
999 \& I 49 C9 C9 C9 49 C9
1000 \& <SOFT HYPHEN> AD CA CA CA C2.AD 80.54
1001 \& <o WITH CIRCUMFLEX> F4 CB CB CB C3.B4 8B.63
1002 \& <o WITH DIAERESIS> F6 CC CC CC C3.B6 8B.65
1003 \& <o WITH GRAVE> F2 CD CD CD C3.B2 8B.59
1004 \& <o WITH ACUTE> F3 CE CE CE C3.B3 8B.62
1005 \& <o WITH TILDE> F5 CF CF CF C3.B5 8B.64
1006 \& } 7D D0 D0 FD 7D D0 ##
1007 \& J 4A D1 D1 D1 4A D1
1008 \& K 4B D2 D2 D2 4B D2
1009 \& L 4C D3 D3 D3 4C D3
1010 \& M 4D D4 D4 D4 4D D4
1011 \& N 4E D5 D5 D5 4E D5
1012 \& O 4F D6 D6 D6 4F D6
1013 \& P 50 D7 D7 D7 50 D7
1014 \& Q 51 D8 D8 D8 51 D8
1015 \& R 52 D9 D9 D9 52 D9
1016 \& <SUPERSCRIPT ONE> B9 DA DA DA C2.B9 80.68
1017 \& <u WITH CIRCUMFLEX> FB DB DB DB C3.BB 8B.6A
1018 \& <u WITH DIAERESIS> FC DC DC DC C3.BC 8B.70
1019 \& <u WITH GRAVE> F9 DD DD C0 C3.B9 8B.68 ##
1020 \& <u WITH ACUTE> FA DE DE DE C3.BA 8B.69
1021 \& <y WITH DIAERESIS> FF DF DF DF C3.BF 8B.73
1022 \& \e 5C E0 E0 BC 5C E0 ##
1023 \& <DIVISION SIGN> F7 E1 E1 E1 C3.B7 8B.66
1024 \& S 53 E2 E2 E2 53 E2
1025 \& T 54 E3 E3 E3 54 E3
1026 \& U 55 E4 E4 E4 55 E4
1027 \& V 56 E5 E5 E5 56 E5
1028 \& W 57 E6 E6 E6 57 E6
1029 \& X 58 E7 E7 E7 58 E7
1030 \& Y 59 E8 E8 E8 59 E8
1031 \& Z 5A E9 E9 E9 5A E9
1032 \& <SUPERSCRIPT TWO> B2 EA EA EA C2.B2 80.59
1033 \& <O WITH CIRCUMFLEX> D4 EB EB EB C3.94 8A.63
1034 \& <O WITH DIAERESIS> D6 EC EC EC C3.96 8A.65
1035 \& <O WITH GRAVE> D2 ED ED ED C3.92 8A.59
1036 \& <O WITH ACUTE> D3 EE EE EE C3.93 8A.62
1037 \& <O WITH TILDE> D5 EF EF EF C3.95 8A.64
1038 \& 0 30 F0 F0 F0 30 F0
1039 \& 1 31 F1 F1 F1 31 F1
1040 \& 2 32 F2 F2 F2 32 F2
1041 \& 3 33 F3 F3 F3 33 F3
1042 \& 4 34 F4 F4 F4 34 F4
1043 \& 5 35 F5 F5 F5 35 F5
1044 \& 6 36 F6 F6 F6 36 F6
1045 \& 7 37 F7 F7 F7 37 F7
1046 \& 8 38 F8 F8 F8 38 F8
1047 \& 9 39 F9 F9 F9 39 F9
1048 \& <SUPERSCRIPT THREE> B3 FA FA FA C2.B3 80.62
1049 \& <U WITH CIRCUMFLEX> DB FB FB DD C3.9B 8A.6A ##
1050 \& <U WITH DIAERESIS> DC FC FC FC C3.9C 8A.70
1051 \& <U WITH GRAVE> D9 FD FD E0 C3.99 8A.68 ##
1052 \& <U WITH ACUTE> DA FE FE FE C3.9A 8A.69
1053 \& <APC> 9F FF FF 5F C2.9F FF ##
1054 .Ve
1055 .SH "IDENTIFYING CHARACTER CODE SETS"
1056 .IX Header "IDENTIFYING CHARACTER CODE SETS"
1057 It is possible to determine which character set you are operating under.
1058 But first you need to be really really sure you need to do this. Your
1059 code will be simpler and probably just as portable if you don\*(Aqt have
1060 to test the character set and do different things, depending. There are
1061 actually only very few circumstances where it\*(Aqs not easy to write
1062 straight\-line code portable to all character sets. See
1063 "Unicode and EBCDIC" in perluniintro for how to portably specify
1064 characters.
1065 .PP
1066 But there are some cases where you may want to know which character set
1067 you are running under. One possible example is doing
1068 sorting in inner loops where performance is critical.
1069 .PP
1070 To determine if you are running under ASCII or EBCDIC, you can use the
1071 return value of \f(CWord()\fR or \f(CWchr()\fR to test one or more character
1072 values. For example:
1073 .PP
1074 .Vb 4
1075 \& $is_ascii = "A" eq chr(65);
1076 \& $is_ebcdic = "A" eq chr(193);
1077 \& $is_ascii = ord("A") == 65;
1078 \& $is_ebcdic = ord("A") == 193;
1079 .Ve
1080 .PP
1081 There\*(Aqs even less need to distinguish between EBCDIC code pages, but to
1082 do so try looking at one or more of the characters that differ between
1083 them.
1084 .PP
1085 .Vb 4
1086 \& $is_ascii = ord(\*(Aq[\*(Aq) == 91;
1087 \& $is_ebcdic_37 = ord(\*(Aq[\*(Aq) == 186;
1088 \& $is_ebcdic_1047 = ord(\*(Aq[\*(Aq) == 173;
1089 \& $is_ebcdic_POSIX_BC = ord(\*(Aq[\*(Aq) == 187;
1090 .Ve
1091 .PP
1092 However, it would be unwise to write tests such as:
1093 .PP
1094 .Vb 2
1095 \& $is_ascii = "\er" ne chr(13); # WRONG
1096 \& $is_ascii = "\en" ne chr(10); # ILL ADVISED
1097 .Ve
1098 .PP
1099 Obviously the first of these will fail to distinguish most ASCII
1100 platforms from either a CCSID 0037, a 1047, or a POSIX\-BC EBCDIC
1101 platform since \f(CW\*(C`"\er"\ eq\ chr(13)\*(C'\fR under all of those coded character
1102 sets. But note too that because \f(CW"\en"\fR is \f(CWchr(13)\fR and \f(CW"\er"\fR is
1103 \&\f(CWchr(10)\fR on old Macintosh (which is an ASCII platform) the second
1104 \&\f(CW$is_ascii\fR test will lead to trouble there.
1105 .PP
1106 To determine whether or not perl was built under an EBCDIC
1107 code page you can use the Config module like so:
1108 .PP
1109 .Vb 2
1110 \& use Config;
1111 \& $is_ebcdic = $Config{\*(Aqebcdic\*(Aq} eq \*(Aqdefine\*(Aq;
1112 .Ve
1113 .SH CONVERSIONS
1114 .IX Header "CONVERSIONS"
1115 .ie n .SS "utf8::unicode_to_native() and utf8::native_to_unicode()"
1116 .el .SS "\f(CWutf8::unicode_to_native()\fP and \f(CWutf8::native_to_unicode()\fP"
1117 .IX Subsection "utf8::unicode_to_native() and utf8::native_to_unicode()"
1118 These functions take an input numeric code point in one encoding and
1119 return what its equivalent value is in the other.
1120 .PP
1121 See utf8.
1122 .SS tr///
1123 .IX Subsection "tr///"
1124 In order to convert a string of characters from one character set to
1125 another a simple list of numbers, such as in the right columns in the
1126 above table, along with Perl\*(Aqs \f(CW\*(C`tr///\*(C'\fR operator is all that is needed.
1127 The data in the table are in ASCII/Latin1 order, hence the EBCDIC columns
1128 provide easy\-to\-use ASCII/Latin1 to EBCDIC operations that are also easily
1129 reversed.
1130 .PP
1131 For example, to convert ASCII/Latin1 to code page 037 take the output of the
1132 second numbers column from the output of recipe 2 (modified to add
1133 \&\f(CW"\e"\fR characters), and use it in \f(CW\*(C`tr///\*(C'\fR like so:
1134 .PP
1135 .Vb 10
1136 \& $cp_037 =
1137 \& \*(Aq\ex00\ex01\ex02\ex03\ex37\ex2D\ex2E\ex2F\ex16\ex05\ex25\ex0B\ex0C\ex0D\ex0E\ex0F\*(Aq .
1138 \& \*(Aq\ex10\ex11\ex12\ex13\ex3C\ex3D\ex32\ex26\ex18\ex19\ex3F\ex27\ex1C\ex1D\ex1E\ex1F\*(Aq .
1139 \& \*(Aq\ex40\ex5A\ex7F\ex7B\ex5B\ex6C\ex50\ex7D\ex4D\ex5D\ex5C\ex4E\ex6B\ex60\ex4B\ex61\*(Aq .
1140 \& \*(Aq\exF0\exF1\exF2\exF3\exF4\exF5\exF6\exF7\exF8\exF9\ex7A\ex5E\ex4C\ex7E\ex6E\ex6F\*(Aq .
1141 \& \*(Aq\ex7C\exC1\exC2\exC3\exC4\exC5\exC6\exC7\exC8\exC9\exD1\exD2\exD3\exD4\exD5\exD6\*(Aq .
1142 \& \*(Aq\exD7\exD8\exD9\exE2\exE3\exE4\exE5\exE6\exE7\exE8\exE9\exBA\exE0\exBB\exB0\ex6D\*(Aq .
1143 \& \*(Aq\ex79\ex81\ex82\ex83\ex84\ex85\ex86\ex87\ex88\ex89\ex91\ex92\ex93\ex94\ex95\ex96\*(Aq .
1144 \& \*(Aq\ex97\ex98\ex99\exA2\exA3\exA4\exA5\exA6\exA7\exA8\exA9\exC0\ex4F\exD0\exA1\ex07\*(Aq .
1145 \& \*(Aq\ex20\ex21\ex22\ex23\ex24\ex15\ex06\ex17\ex28\ex29\ex2A\ex2B\ex2C\ex09\ex0A\ex1B\*(Aq .
1146 \& \*(Aq\ex30\ex31\ex1A\ex33\ex34\ex35\ex36\ex08\ex38\ex39\ex3A\ex3B\ex04\ex14\ex3E\exFF\*(Aq .
1147 \& \*(Aq\ex41\exAA\ex4A\exB1\ex9F\exB2\ex6A\exB5\exBD\exB4\ex9A\ex8A\ex5F\exCA\exAF\exBC\*(Aq .
1148 \& \*(Aq\ex90\ex8F\exEA\exFA\exBE\exA0\exB6\exB3\ex9D\exDA\ex9B\ex8B\exB7\exB8\exB9\exAB\*(Aq .
1149 \& \*(Aq\ex64\ex65\ex62\ex66\ex63\ex67\ex9E\ex68\ex74\ex71\ex72\ex73\ex78\ex75\ex76\ex77\*(Aq .
1150 \& \*(Aq\exAC\ex69\exED\exEE\exEB\exEF\exEC\exBF\ex80\exFD\exFE\exFB\exFC\exAD\exAE\ex59\*(Aq .
1151 \& \*(Aq\ex44\ex45\ex42\ex46\ex43\ex47\ex9C\ex48\ex54\ex51\ex52\ex53\ex58\ex55\ex56\ex57\*(Aq .
1152 \& \*(Aq\ex8C\ex49\exCD\exCE\exCB\exCF\exCC\exE1\ex70\exDD\exDE\exDB\exDC\ex8D\ex8E\exDF\*(Aq;
1153 \&
1154 \& my $ebcdic_string = $ascii_string;
1155 \& eval \*(Aq$ebcdic_string =~ tr/\e000\-\e377/\*(Aq . $cp_037 . \*(Aq/\*(Aq;
1156 .Ve
1157 .PP
1158 To convert from EBCDIC 037 to ASCII just reverse the order of the tr///
1159 arguments like so:
1160 .PP
1161 .Vb 2
1162 \& my $ascii_string = $ebcdic_string;
1163 \& eval \*(Aq$ascii_string =~ tr/\*(Aq . $cp_037 . \*(Aq/\e000\-\e377/\*(Aq;
1164 .Ve
1165 .PP
1166 Similarly one could take the output of the third numbers column from recipe 2
1167 to obtain a \f(CW$cp_1047\fR table. The fourth numbers column of the output from
1168 recipe 2 could provide a \f(CW$cp_posix_bc\fR table suitable for transcoding as
1169 well.
1170 .PP
1171 If you wanted to see the inverse tables, you would first have to sort on the
1172 desired numbers column as in recipes 4, 5 or 6, then take the output of the
1173 first numbers column.
1174 .SS iconv
1175 .IX Subsection "iconv"
1176 XPG operability often implies the presence of an \fIiconv\fR utility
1177 available from the shell or from the C library. Consult your system\*(Aqs
1178 documentation for information on iconv.
1179 .PP
1180 On OS/390 or z/OS see the \fBiconv\fR\|(1) manpage. One way to invoke the \f(CW\*(C`iconv\*(C'\fR
1181 shell utility from within perl would be to:
1182 .PP
1183 .Vb 2
1184 \& # OS/390 or z/OS example
1185 \& $ascii_data = \`echo \*(Aq$ebcdic_data\*(Aq| iconv \-f IBM\-1047 \-t ISO8859\-1\`
1186 .Ve
1187 .PP
1188 or the inverse map:
1189 .PP
1190 .Vb 2
1191 \& # OS/390 or z/OS example
1192 \& $ebcdic_data = \`echo \*(Aq$ascii_data\*(Aq| iconv \-f ISO8859\-1 \-t IBM\-1047\`
1193 .Ve
1194 .PP
1195 For other Perl\-based conversion options see the \f(CW\*(C`Convert::*\*(C'\fR modules on CPAN.
1196 .SS "C RTL"
1197 .IX Subsection "C RTL"
1198 The OS/390 and z/OS C run\-time libraries provide \f(CW_atoe()\fR and \f(CW_etoa()\fR functions.
1199 .SH "OPERATOR DIFFERENCES"
1200 .IX Header "OPERATOR DIFFERENCES"
1201 The \f(CW\*(C`..\*(C'\fR range operator treats certain character ranges with
1202 care on EBCDIC platforms. For example the following array
1203 will have twenty six elements on either an EBCDIC platform
1204 or an ASCII platform:
1205 .PP
1206 .Vb 1
1207 \& @alphabet = (\*(AqA\*(Aq..\*(AqZ\*(Aq); # $#alphabet == 25
1208 .Ve
1209 .PP
1210 The bitwise operators such as & ^ | may return different results
1211 when operating on string or character data in a Perl program running
1212 on an EBCDIC platform than when run on an ASCII platform. Here is
1213 an example adapted from the one in perlop:
1214 .PP
1215 .Vb 5
1216 \& # EBCDIC\-based examples
1217 \& print "j p \en" ^ " a h"; # prints "JAPH\en"
1218 \& print "JA" | " ph\en"; # prints "japh\en"
1219 \& print "JAPH\enJunk" & "\e277\e277\e277\e277\e277"; # prints "japh\en";
1220 \& print \*(Aqp N$\*(Aq ^ " E<H\en"; # prints "Perl\en";
1221 .Ve
1222 .PP
1223 An interesting property of the 32 C0 control characters
1224 in the ASCII table is that they can "literally" be constructed
1225 as control characters in Perl, e.g. \f(CW\*(C`(chr(0)\*(C'\fR eq \f(CW\*(C`\ec@\*(C'\fR)>
1226 \&\f(CW\*(C`(chr(1)\*(C'\fR eq \f(CW\*(C`\ecA\*(C'\fR)>, and so on. Perl on EBCDIC platforms has been
1227 ported to take \f(CW\*(C`\ec@\*(C'\fR to \f(CWchr(0)\fR and \f(CW\*(C`\ecA\*(C'\fR to \f(CWchr(1)\fR, etc. as well, but the
1228 characters that result depend on which code page you are
1229 using. The table below uses the standard acronyms for the controls.
1230 The POSIX\-BC and 1047 sets are
1231 identical throughout this range and differ from the 0037 set at only
1232 one spot (21 decimal). Note that the line terminator character
1233 may be generated by \f(CW\*(C`\ecJ\*(C'\fR on ASCII platforms but by \f(CW\*(C`\ecU\*(C'\fR on 1047 or POSIX\-BC
1234 platforms and cannot be generated as a \f(CW"\ec.letter."\fR control character on
1235 0037 platforms. Note also that \f(CW\*(C`\ec\e\*(C'\fR cannot be the final element in a string
1236 or regex, as it will absorb the terminator. But \f(CW\*(C`\ec\e\fR\f(CIX\fR\f(CW\*(C'\fR is a \f(CW\*(C`FILE
1237 SEPARATOR\*(C'\fR concatenated with \fIX\fR for all \fIX\fR.
1238 The outlier \f(CW\*(C`\ec?\*(C'\fR on ASCII, which yields a non\-C0 control \f(CW\*(C`DEL\*(C'\fR,
1239 yields the outlier control \f(CW\*(C`APC\*(C'\fR on EBCDIC, the one that isn\*(Aqt in the
1240 block of contiguous controls. Note that a subtlety of this is that
1241 \&\f(CW\*(C`\ec?\*(C'\fR on ASCII platforms is an ASCII character, while it isn\*(Aqt
1242 equivalent to any ASCII character in EBCDIC platforms.
1243 .PP
1244 .Vb 10
1245 \& chr ord 8859\-1 0037 1047 && POSIX\-BC
1246 \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
1247 \& \ec@ 0 <NUL> <NUL> <NUL>
1248 \& \ecA 1 <SOH> <SOH> <SOH>
1249 \& \ecB 2 <STX> <STX> <STX>
1250 \& \ecC 3 <ETX> <ETX> <ETX>
1251 \& \ecD 4 <EOT> <ST> <ST>
1252 \& \ecE 5 <ENQ> <HT> <HT>
1253 \& \ecF 6 <ACK> <SSA> <SSA>
1254 \& \ecG 7 <BEL> <DEL> <DEL>
1255 \& \ecH 8 <BS> <EPA> <EPA>
1256 \& \ecI 9 <HT> <RI> <RI>
1257 \& \ecJ 10 <LF> <SS2> <SS2>
1258 \& \ecK 11 <VT> <VT> <VT>
1259 \& \ecL 12 <FF> <FF> <FF>
1260 \& \ecM 13 <CR> <CR> <CR>
1261 \& \ecN 14 <SO> <SO> <SO>
1262 \& \ecO 15 <SI> <SI> <SI>
1263 \& \ecP 16 <DLE> <DLE> <DLE>
1264 \& \ecQ 17 <DC1> <DC1> <DC1>
1265 \& \ecR 18 <DC2> <DC2> <DC2>
1266 \& \ecS 19 <DC3> <DC3> <DC3>
1267 \& \ecT 20 <DC4> <OSC> <OSC>
1268 \& \ecU 21 <NAK> <NEL> <LF> **
1269 \& \ecV 22 <SYN> <BS> <BS>
1270 \& \ecW 23 <ETB> <ESA> <ESA>
1271 \& \ecX 24 <CAN> <CAN> <CAN>
1272 \& \ecY 25 <EOM> <EOM> <EOM>
1273 \& \ecZ 26 <SUB> <PU2> <PU2>
1274 \& \ec[ 27 <ESC> <SS3> <SS3>
1275 \& \ec\eX 28 <FS>X <FS>X <FS>X
1276 \& \ec] 29 <GS> <GS> <GS>
1277 \& \ec^ 30 <RS> <RS> <RS>
1278 \& \ec_ 31 <US> <US> <US>
1279 \& \ec? * <DEL> <APC> <APC>
1280 .Ve
1281 .PP
1282 \&\f(CW\*(C`*\*(C'\fR Note: \f(CW\*(C`\ec?\*(C'\fR maps to ordinal 127 (\f(CW\*(C`DEL\*(C'\fR) on ASCII platforms, but
1283 since ordinal 127 is a not a control character on EBCDIC machines,
1284 \&\f(CW\*(C`\ec?\*(C'\fR instead maps on them to \f(CW\*(C`APC\*(C'\fR, which is 255 in 0037 and 1047,
1285 and 95 in POSIX\-BC.
1286 .SH "FUNCTION DIFFERENCES"
1287 .IX Header "FUNCTION DIFFERENCES"
1288 .ie n .IP chr() 8
1289 .el .IP \f(CWchr()\fR 8
1290 .IX Item "chr()"
1291 \&\f(CWchr()\fR must be given an EBCDIC code number argument to yield a desired
1292 character return value on an EBCDIC platform. For example:
1293 .Sp
1294 .Vb 1
1295 \& $CAPITAL_LETTER_A = chr(193);
1296 .Ve
1297 .ie n .IP ord() 8
1298 .el .IP \f(CWord()\fR 8
1299 .IX Item "ord()"
1300 \&\f(CWord()\fR will return EBCDIC code number values on an EBCDIC platform.
1301 For example:
1302 .Sp
1303 .Vb 1
1304 \& $the_number_193 = ord("A");
1305 .Ve
1306 .ie n .IP pack() 8
1307 .el .IP \f(CWpack()\fR 8
1308 .IX Item "pack()"
1309 The \f(CW"c"\fR and \f(CW"C"\fR templates for \f(CWpack()\fR are dependent upon character set
1310 encoding. Examples of usage on EBCDIC include:
1311 .Sp
1312 .Vb 4
1313 \& $foo = pack("CCCC",193,194,195,196);
1314 \& # $foo eq "ABCD"
1315 \& $foo = pack("C4",193,194,195,196);
1316 \& # same thing
1317 \&
1318 \& $foo = pack("ccxxcc",193,194,195,196);
1319 \& # $foo eq "AB\e0\e0CD"
1320 .Ve
1321 .Sp
1322 The \f(CW"U"\fR template has been ported to mean "Unicode" on all platforms so
1323 that
1324 .Sp
1325 .Vb 1
1326 \& pack("U", 65) eq \*(AqA\*(Aq
1327 .Ve
1328 .Sp
1329 is true on all platforms. If you want native code points for the low
1330 256, use the \f(CW"W"\fR template. This means that the equivalences
1331 .Sp
1332 .Vb 2
1333 \& pack("W", ord($character)) eq $character
1334 \& unpack("W", $character) == ord $character
1335 .Ve
1336 .Sp
1337 will hold.
1338 .ie n .IP print() 8
1339 .el .IP \f(CWprint()\fR 8
1340 .IX Item "print()"
1341 One must be careful with scalars and strings that are passed to
1342 print that contain ASCII encodings. One common place
1343 for this to occur is in the output of the MIME type header for
1344 CGI script writing. For example, many Perl programming guides
1345 recommend something similar to:
1346 .Sp
1347 .Vb 2
1348 \& print "Content\-type:\ettext/html\e015\e012\e015\e012";
1349 \& # this may be wrong on EBCDIC
1350 .Ve
1351 .Sp
1352 You can instead write
1353 .Sp
1354 .Vb 1
1355 \& print "Content\-type:\ettext/html\er\en\er\en"; # OK for DGW et al
1356 .Ve
1357 .Sp
1358 and have it work portably.
1359 .Sp
1360 That is because the translation from EBCDIC to ASCII is done
1361 by the web server in this case. Consult your web server\*(Aqs documentation for
1362 further details.
1363 .ie n .IP printf() 8
1364 .el .IP \f(CWprintf()\fR 8
1365 .IX Item "printf()"
1366 The formats that can convert characters to numbers and vice versa
1367 will be different from their ASCII counterparts when executed
1368 on an EBCDIC platform. Examples include:
1369 .Sp
1370 .Vb 1
1371 \& printf("%c%c%c",193,194,195); # prints ABC
1372 .Ve
1373 .ie n .IP sort() 8
1374 .el .IP \f(CWsort()\fR 8
1375 .IX Item "sort()"
1376 EBCDIC sort results may differ from ASCII sort results especially for
1377 mixed case strings. This is discussed in more detail below.
1378 .ie n .IP sprintf() 8
1379 .el .IP \f(CWsprintf()\fR 8
1380 .IX Item "sprintf()"
1381 See the discussion of \f(CW"printf()"\fR above. An example of the use
1382 of sprintf would be:
1383 .Sp
1384 .Vb 1
1385 \& $CAPITAL_LETTER_A = sprintf("%c",193);
1386 .Ve
1387 .ie n .IP unpack() 8
1388 .el .IP \f(CWunpack()\fR 8
1389 .IX Item "unpack()"
1390 See the discussion of \f(CW"pack()"\fR above.
1391 .PP
1392 Note that it is possible to write portable code for these by specifying
1393 things in Unicode numbers, and using a conversion function:
1394 .PP
1395 .Vb 3
1396 \& printf("%c",utf8::unicode_to_native(65)); # prints A on all
1397 \& # platforms
1398 \& print utf8::native_to_unicode(ord("A")); # Likewise, prints 65
1399 .Ve
1400 .PP
1401 See "Unicode and EBCDIC" in perluniintro and "CONVERSIONS"
1402 for other options.
1403 .SH "REGULAR EXPRESSION DIFFERENCES"
1404 .IX Header "REGULAR EXPRESSION DIFFERENCES"
1405 You can write your regular expressions just like someone on an ASCII
1406 platform would do. But keep in mind that using octal or hex notation to
1407 specify a particular code point will give you the character that the
1408 EBCDIC code page natively maps to it. (This is also true of all
1409 double\-quoted strings.) If you want to write portably, just use the
1410 \&\f(CW\*(C`\eN{U+...}\*(C'\fR notation everywhere where you would have used \f(CW\*(C`\ex{...}\*(C'\fR,
1411 and don\*(Aqt use octal notation at all.
1412 .PP
1413 Starting in Perl v5.22, this applies to ranges in bracketed character
1414 classes. If you say, for example, \f(CW\*(C`qr/[\eN{U+20}\-\eN{U+7F}]/\*(C'\fR, it means
1415 the characters \f(CW\*(C`\eN{U+20}\*(C'\fR, \f(CW\*(C`\eN{U+21}\*(C'\fR, ..., \f(CW\*(C`\eN{U+7F}\*(C'\fR. This range
1416 is all the printable characters that the ASCII character set contains.
1417 .PP
1418 Prior to v5.22, you couldn\*(Aqt specify any ranges portably, except
1419 (starting in Perl v5.5.3) all subsets of the \f(CW\*(C`[A\-Z]\*(C'\fR and \f(CW\*(C`[a\-z]\*(C'\fR
1420 ranges are specially coded to not pick up gap characters. For example,
1421 characters such as "ô" (\f(CW\*(C`o WITH CIRCUMFLEX\*(C'\fR) that lie between
1422 "I" and "J" would not be matched by the regular expression range
1423 \&\f(CW\*(C`/[H\-K]/\*(C'\fR. But if either of the range end points is explicitly numeric
1424 (and neither is specified by \f(CW\*(C`\eN{U+...}\*(C'\fR), the gap characters are
1425 matched:
1426 .PP
1427 .Vb 1
1428 \& /[\ex89\-\ex91]/
1429 .Ve
1430 .PP
1431 will match \f(CW\*(C`\ex8e\*(C'\fR, even though \f(CW\*(C`\ex89\*(C'\fR is "i" and \f(CW\*(C`\ex91 \*(C'\fR is "j",
1432 and \f(CW\*(C`\ex8e\*(C'\fR is a gap character, from the alphabetic viewpoint.
1433 .PP
1434 Another construct to be wary of is the inappropriate use of hex (unless
1435 you use \f(CW\*(C`\eN{U+...}\*(C'\fR) or
1436 octal constants in regular expressions. Consider the following
1437 set of subs:
1438 .PP
1439 .Vb 4
1440 \& sub is_c0 {
1441 \& my $char = substr(shift,0,1);
1442 \& $char =~ /[\e000\-\e037]/;
1443 \& }
1444 \&
1445 \& sub is_print_ascii {
1446 \& my $char = substr(shift,0,1);
1447 \& $char =~ /[\e040\-\e176]/;
1448 \& }
1449 \&
1450 \& sub is_delete {
1451 \& my $char = substr(shift,0,1);
1452 \& $char eq "\e177";
1453 \& }
1454 \&
1455 \& sub is_c1 {
1456 \& my $char = substr(shift,0,1);
1457 \& $char =~ /[\e200\-\e237]/;
1458 \& }
1459 \&
1460 \& sub is_latin_1 { # But not ASCII; not C1
1461 \& my $char = substr(shift,0,1);
1462 \& $char =~ /[\e240\-\e377]/;
1463 \& }
1464 .Ve
1465 .PP
1466 These are valid only on ASCII platforms. Starting in Perl v5.22, simply
1467 changing the octal constants to equivalent \f(CW\*(C`\eN{U+...}\*(C'\fR values makes
1468 them portable:
1469 .PP
1470 .Vb 4
1471 \& sub is_c0 {
1472 \& my $char = substr(shift,0,1);
1473 \& $char =~ /[\eN{U+00}\-\eN{U+1F}]/;
1474 \& }
1475 \&
1476 \& sub is_print_ascii {
1477 \& my $char = substr(shift,0,1);
1478 \& $char =~ /[\eN{U+20}\-\eN{U+7E}]/;
1479 \& }
1480 \&
1481 \& sub is_delete {
1482 \& my $char = substr(shift,0,1);
1483 \& $char eq "\eN{U+7F}";
1484 \& }
1485 \&
1486 \& sub is_c1 {
1487 \& my $char = substr(shift,0,1);
1488 \& $char =~ /[\eN{U+80}\-\eN{U+9F}]/;
1489 \& }
1490 \&
1491 \& sub is_latin_1 { # But not ASCII; not C1
1492 \& my $char = substr(shift,0,1);
1493 \& $char =~ /[\eN{U+A0}\-\eN{U+FF}]/;
1494 \& }
1495 .Ve
1496 .PP
1497 And here are some alternative portable ways to write them:
1498 .PP
1499 .Vb 3
1500 \& sub Is_c0 {
1501 \& my $char = substr(shift,0,1);
1502 \& return $char =~ /[[:cntrl:]]/a && ! Is_delete($char);
1503 \&
1504 \& # Alternatively:
1505 \& # return $char =~ /[[:cntrl:]]/
1506 \& # && $char =~ /[[:ascii:]]/
1507 \& # && ! Is_delete($char);
1508 \& }
1509 \&
1510 \& sub Is_print_ascii {
1511 \& my $char = substr(shift,0,1);
1512 \&
1513 \& return $char =~ /[[:print:]]/a;
1514 \&
1515 \& # Alternatively:
1516 \& # return $char =~ /[[:print:]]/ && $char =~ /[[:ascii:]]/;
1517 \&
1518 \& # Or
1519 \& # return $char
1520 \& # =~ /[ !"\e#\e$%&\*(Aq()*+,\e\-.\e/0\-9:;<=>?\e@A\-Z[\e\e\e]^_\`a\-z{|}~]/;
1521 \& }
1522 \&
1523 \& sub Is_delete {
1524 \& my $char = substr(shift,0,1);
1525 \& return utf8::native_to_unicode(ord $char) == 0x7F;
1526 \& }
1527 \&
1528 \& sub Is_c1 {
1529 \& use feature \*(Aqunicode_strings\*(Aq;
1530 \& my $char = substr(shift,0,1);
1531 \& return $char =~ /[[:cntrl:]]/ && $char !~ /[[:ascii:]]/;
1532 \& }
1533 \&
1534 \& sub Is_latin_1 { # But not ASCII; not C1
1535 \& use feature \*(Aqunicode_strings\*(Aq;
1536 \& my $char = substr(shift,0,1);
1537 \& return ord($char) < 256
1538 \& && $char !~ /[[:ascii:]]/
1539 \& && $char !~ /[[:cntrl:]]/;
1540 \& }
1541 .Ve
1542 .PP
1543 Another way to write \f(CWIs_latin_1()\fR would be
1544 to use the characters in the range explicitly:
1545 .PP
1546 .Vb 5
1547 \& sub Is_latin_1 {
1548 \& my $char = substr(shift,0,1);
1549 \& $char =~ /[\ ¡¢£¤¥¦§¨©ª«¬\%®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ]
1550 \& [ÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ]/x;
1551 \& }
1552 .Ve
1553 .PP
1554 Although that form may run into trouble in network transit (due to the
1555 presence of 8 bit characters) or on non ISO\-Latin character sets. But
1556 it does allow \f(CW\*(C`Is_c1\*(C'\fR to be rewritten so it works on Perls that don\*(Aqt
1557 have \f(CW\*(Aqunicode_strings\*(Aq\fR (earlier than v5.14):
1558 .PP
1559 .Vb 6
1560 \& sub Is_latin_1 { # But not ASCII; not C1
1561 \& my $char = substr(shift,0,1);
1562 \& return ord($char) < 256
1563 \& && $char !~ /[[:ascii:]]/
1564 \& && ! Is_latin1($char);
1565 \& }
1566 .Ve
1567 .SH SOCKETS
1568 .IX Header "SOCKETS"
1569 Most socket programming assumes ASCII character encodings in network
1570 byte order. Exceptions can include CGI script writing under a
1571 host web server where the server may take care of translation for you.
1572 Most host web servers convert EBCDIC data to ISO\-8859\-1 or Unicode on
1573 output.
1574 .SH SORTING
1575 .IX Header "SORTING"
1576 One big difference between ASCII\-based character sets and EBCDIC ones
1577 are the relative positions of the characters when sorted in native
1578 order. Of most concern are the upper\- and lowercase letters, the
1579 digits, and the underscore (\f(CW"_"\fR). On ASCII platforms the native sort
1580 order has the digits come before the uppercase letters which come before
1581 the underscore which comes before the lowercase letters. On EBCDIC, the
1582 underscore comes first, then the lowercase letters, then the uppercase
1583 ones, and the digits last. If sorted on an ASCII\-based platform, the
1584 two\-letter abbreviation for a physician comes before the two letter
1585 abbreviation for drive; that is:
1586 .PP
1587 .Vb 2
1588 \& @sorted = sort(qw(Dr. dr.)); # @sorted holds (\*(AqDr.\*(Aq,\*(Aqdr.\*(Aq) on ASCII,
1589 \& # but (\*(Aqdr.\*(Aq,\*(AqDr.\*(Aq) on EBCDIC
1590 .Ve
1591 .PP
1592 The property of lowercase before uppercase letters in EBCDIC is
1593 even carried to the Latin 1 EBCDIC pages such as 0037 and 1047.
1594 An example would be that "Ë" (\f(CW\*(C`E WITH DIAERESIS\*(C'\fR, 203) comes
1595 before "ë" (\f(CW\*(C`e WITH DIAERESIS\*(C'\fR, 235) on an ASCII platform, but
1596 the latter (83) comes before the former (115) on an EBCDIC platform.
1597 (Astute readers will note that the uppercase version of "ß"
1598 \&\f(CW\*(C`SMALL LETTER SHARP S\*(C'\fR is simply "SS" and that the upper case versions
1599 of "ÿ" (small \f(CW\*(C`y WITH DIAERESIS\*(C'\fR) and "µ" (\f(CW\*(C`MICRO SIGN\*(C'\fR)
1600 are not in the 0..255 range but are in Unicode, in a Unicode enabled
1601 Perl).
1602 .PP
1603 The sort order will cause differences between results obtained on
1604 ASCII platforms versus EBCDIC platforms. What follows are some suggestions
1605 on how to deal with these differences.
1606 .SS "Ignore ASCII vs. EBCDIC sort differences"
1607 .IX Subsection "Ignore ASCII vs. EBCDIC sort differences"
1608 This is the least computationally expensive strategy. It may require
1609 some user education.
1610 .SS "Use a sort helper function"
1611 .IX Subsection "Use a sort helper function"
1612 This is completely general, but the most computationally expensive
1613 strategy. Choose one or the other character set and transform to that
1614 for every sort comparison. Here\*(Aqs a complete example that transforms
1615 to ASCII sort order:
1616 .PP
1617 .Vb 2
1618 \& sub native_to_uni($) {
1619 \& my $string = shift;
1620 \&
1621 \& # Saves time on an ASCII platform
1622 \& return $string if ord \*(AqA\*(Aq == 65;
1623 \&
1624 \& my $output = "";
1625 \& for my $i (0 .. length($string) \- 1) {
1626 \& $output
1627 \& .= chr(utf8::native_to_unicode(ord(substr($string, $i, 1))));
1628 \& }
1629 \&
1630 \& # Preserve utf8ness of input onto the output, even if it didn\*(Aqt need
1631 \& # to be utf8
1632 \& utf8::upgrade($output) if utf8::is_utf8($string);
1633 \&
1634 \& return $output;
1635 \& }
1636 \&
1637 \& sub ascii_order { # Sort helper
1638 \& return native_to_uni($a) cmp native_to_uni($b);
1639 \& }
1640 \&
1641 \& sort ascii_order @list;
1642 .Ve
1643 .SS "MONO CASE then sort data (for non\-digits, non\-underscore)"
1644 .IX Subsection "MONO CASE then sort data (for non-digits, non-underscore)"
1645 If you don\*(Aqt care about where digits and underscore sort to, you can do
1646 something like this
1647 .PP
1648 .Vb 3
1649 \& sub case_insensitive_order { # Sort helper
1650 \& return lc($a) cmp lc($b)
1651 \& }
1652 \&
1653 \& sort case_insensitive_order @list;
1654 .Ve
1655 .PP
1656 If performance is an issue, and you don\*(Aqt care if the output is in the
1657 same case as the input, Use \f(CW\*(C`tr///\*(C'\fR to transform to the case most
1658 employed within the data. If the data are primarily UPPERCASE
1659 non\-Latin1, then apply \f(CW\*(C`tr/[a\-z]/[A\-Z]/\*(C'\fR, and then \f(CWsort()\fR. If the
1660 data are primarily lowercase non Latin1 then apply \f(CW\*(C`tr/[A\-Z]/[a\-z]/\*(C'\fR
1661 before sorting. If the data are primarily UPPERCASE and include Latin\-1
1662 characters then apply:
1663 .PP
1664 .Vb 3
1665 \& tr/[a\-z]/[A\-Z]/;
1666 \& tr/[àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ]/[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ/;
1667 \& s/ß/SS/g;
1668 .Ve
1669 .PP
1670 then \f(CWsort()\fR. If you have a choice, it\*(Aqs better to lowercase things
1671 to avoid the problems of the two Latin\-1 characters whose uppercase is
1672 outside Latin\-1: "ÿ" (small \f(CW\*(C`y WITH DIAERESIS\*(C'\fR) and "µ"
1673 (\f(CW\*(C`MICRO SIGN\*(C'\fR). If you do need to uppercase, you can; with a
1674 Unicode\-enabled Perl, do:
1675 .PP
1676 .Vb 2
1677 \& tr/ÿ/\ex{178}/;
1678 \& tr/µ/\ex{39C}/;
1679 .Ve
1680 .SS "Perform sorting on one type of platform only"
1681 .IX Subsection "Perform sorting on one type of platform only"
1682 This strategy can employ a network connection. As such
1683 it would be computationally expensive.
1684 .SH "TRANSFORMATION FORMATS"
1685 .IX Header "TRANSFORMATION FORMATS"
1686 There are a variety of ways of transforming data with an intra character set
1687 mapping that serve a variety of purposes. Sorting was discussed in the
1688 previous section and a few of the other more popular mapping techniques are
1689 discussed next.
1690 .SS "URL decoding and encoding"
1691 .IX Subsection "URL decoding and encoding"
1692 Note that some URLs have hexadecimal ASCII code points in them in an
1693 attempt to overcome character or protocol limitation issues. For example
1694 the tilde character is not on every keyboard hence a URL of the form:
1695 .PP
1696 .Vb 1
1697 \& http://www.pvhp.com/~pvhp/
1698 .Ve
1699 .PP
1700 may also be expressed as either of:
1701 .PP
1702 .Vb 1
1703 \& http://www.pvhp.com/%7Epvhp/
1704 \&
1705 \& http://www.pvhp.com/%7epvhp/
1706 .Ve
1707 .PP
1708 where 7E is the hexadecimal ASCII code point for "~". Here is an example
1709 of decoding such a URL in any EBCDIC code page:
1710 .PP
1711 .Vb 3
1712 \& $url = \*(Aqhttp://www.pvhp.com/%7Epvhp/\*(Aq;
1713 \& $url =~ s/%([0\-9a\-fA\-F]{2})/
1714 \& pack("c",utf8::unicode_to_native(hex($1)))/xge;
1715 .Ve
1716 .PP
1717 Conversely, here is a partial solution for the task of encoding such
1718 a URL in any EBCDIC code page:
1719 .PP
1720 .Vb 5
1721 \& $url = \*(Aqhttp://www.pvhp.com/~pvhp/\*(Aq;
1722 \& # The following regular expression does not address the
1723 \& # mappings for: (\*(Aq.\*(Aq => \*(Aq%2E\*(Aq, \*(Aq/\*(Aq => \*(Aq%2F\*(Aq, \*(Aq:\*(Aq => \*(Aq%3A\*(Aq)
1724 \& $url =~ s/([\et "#%&\e(\e),;<=>\e?\e@\e[\e\e\e]^\`{|}~])/
1725 \& sprintf("%%%02X",utf8::native_to_unicode(ord($1)))/xge;
1726 .Ve
1727 .PP
1728 where a more complete solution would split the URL into components
1729 and apply a full s/// substitution only to the appropriate parts.
1730 .SS "uu encoding and decoding"
1731 .IX Subsection "uu encoding and decoding"
1732 The \f(CW\*(C`u\*(C'\fR template to \f(CWpack()\fR or \f(CWunpack()\fR will render EBCDIC data in
1733 EBCDIC characters equivalent to their ASCII counterparts. For example,
1734 the following will print "Yes indeed\en" on either an ASCII or EBCDIC
1735 computer:
1736 .PP
1737 .Vb 10
1738 \& $all_byte_chrs = \*(Aq\*(Aq;
1739 \& for (0..255) { $all_byte_chrs .= chr($_); }
1740 \& $uuencode_byte_chrs = pack(\*(Aqu\*(Aq, $all_byte_chrs);
1741 \& ($uu = <<\*(AqENDOFHEREDOC\*(Aq) =~ s/^\es*//gm;
1742 \& M\`\`$"\`P0%!@<("0H+#\`T.#Q\`1$A,4%187&!D:&QP=\*(AqA\e@(2(C)"4F)R@I*BLL
1743 \& M+2XO,#$R,S0U\-C<X.3H[/#T^/T!!0D\-$149\*(Aq2$E*2TQ\-3D]045)35%565UA9
1744 \& M6EM<75Y?8&%B8V1E9F=H:6IK;&UN;W!Q<G\-T=79W>\*(AqEZ>WQ]?G^\`@8*#A(6&
1745 \& MAXB)BHN,C8Z/D)&2DY25EI>8F9J;G)V>GZ"AHJ.DI::GJ*FJJZRMKJ^PL;*S
1746 \& MM+6VM[BYNKN\eO;Z_P,\*(Aq"P\e3%QL?(R<K+S,W.S]#1TM/4U=;7V\-G:V]S=WM_@
1747 \& ?X>+CY.7FY^CIZNOL[>[O\e/\*(AqR\e_3U]O?X^?K[_/W^_P\`\`
1748 \& ENDOFHEREDOC
1749 \& if ($uuencode_byte_chrs eq $uu) {
1750 \& print "Yes ";
1751 \& }
1752 \& $uudecode_byte_chrs = unpack(\*(Aqu\*(Aq, $uuencode_byte_chrs);
1753 \& if ($uudecode_byte_chrs eq $all_byte_chrs) {
1754 \& print "indeed\en";
1755 \& }
1756 .Ve
1757 .PP
1758 Here is a very spartan uudecoder that will work on EBCDIC:
1759 .PP
1760 .Vb 10
1761 \& #!/usr/local/bin/perl
1762 \& $_ = <> until ($mode,$file) = /^begin\es*(\ed*)\es*(\eS*)/;
1763 \& open(OUT, "> $file") if $file ne "";
1764 \& while(<>) {
1765 \& last if /^end/;
1766 \& next if /[a\-z]/;
1767 \& next unless int((((utf8::native_to_unicode(ord()) \- 32 ) & 077)
1768 \& + 2) / 3)
1769 \& == int(length() / 4);
1770 \& print OUT unpack("u", $_);
1771 \& }
1772 \& close(OUT);
1773 \& chmod oct($mode), $file;
1774 .Ve
1775 .SS "Quoted\-Printable encoding and decoding"
1776 .IX Subsection "Quoted-Printable encoding and decoding"
1777 On ASCII\-encoded platforms it is possible to strip characters outside of
1778 the printable set using:
1779 .PP
1780 .Vb 3
1781 \& # This QP encoder works on ASCII only
1782 \& $qp_string =~ s/([=\ex00\-\ex1F\ex80\-\exFF])/
1783 \& sprintf("=%02X",ord($1))/xge;
1784 .Ve
1785 .PP
1786 Starting in Perl v5.22, this is trivially changeable to work portably on
1787 both ASCII and EBCDIC platforms.
1788 .PP
1789 .Vb 3
1790 \& # This QP encoder works on both ASCII and EBCDIC
1791 \& $qp_string =~ s/([=\eN{U+00}\-\eN{U+1F}\eN{U+80}\-\eN{U+FF}])/
1792 \& sprintf("=%02X",ord($1))/xge;
1793 .Ve
1794 .PP
1795 For earlier Perls, a QP encoder that works on both ASCII and EBCDIC
1796 platforms would look somewhat like the following:
1797 .PP
1798 .Vb 4
1799 \& $delete = utf8::unicode_to_native(ord("\ex7F"));
1800 \& $qp_string =~
1801 \& s/([^[:print:]$delete])/
1802 \& sprintf("=%02X",utf8::native_to_unicode(ord($1)))/xage;
1803 .Ve
1804 .PP
1805 (although in production code the substitutions might be done
1806 in the EBCDIC branch with the function call and separately in the
1807 ASCII branch without the expense of the identity map; in Perl v5.22, the
1808 identity map is optimized out so there is no expense, but the
1809 alternative above is simpler and is also available in v5.22).
1810 .PP
1811 Such QP strings can be decoded with:
1812 .PP
1813 .Vb 3
1814 \& # This QP decoder is limited to ASCII only
1815 \& $string =~ s/=([[:xdigit:][[:xdigit:])/chr hex $1/ge;
1816 \& $string =~ s/=[\en\er]+$//;
1817 .Ve
1818 .PP
1819 Whereas a QP decoder that works on both ASCII and EBCDIC platforms
1820 would look somewhat like the following:
1821 .PP
1822 .Vb 3
1823 \& $string =~ s/=([[:xdigit:][:xdigit:]])/
1824 \& chr utf8::native_to_unicode(hex $1)/xge;
1825 \& $string =~ s/=[\en\er]+$//;
1826 .Ve
1827 .SS "Caesarean ciphers"
1828 .IX Subsection "Caesarean ciphers"
1829 The practice of shifting an alphabet one or more characters for encipherment
1830 dates back thousands of years and was explicitly detailed by Gaius Julius
1831 Caesar in his \fBGallic Wars\fR text. A single alphabet shift is sometimes
1832 referred to as a rotation and the shift amount is given as a number \f(CW$n\fR after
1833 the string \*(Aqrot\*(Aq or "rot$n". Rot0 and rot26 would designate identity maps
1834 on the 26\-letter English version of the Latin alphabet. Rot13 has the
1835 interesting property that alternate subsequent invocations are identity maps
1836 (thus rot13 is its own non\-trivial inverse in the group of 26 alphabet
1837 rotations). Hence the following is a rot13 encoder and decoder that will
1838 work on ASCII and EBCDIC platforms:
1839 .PP
1840 .Vb 1
1841 \& #!/usr/local/bin/perl
1842 \&
1843 \& while(<>){
1844 \& tr/n\-za\-mN\-ZA\-M/a\-zA\-Z/;
1845 \& print;
1846 \& }
1847 .Ve
1848 .PP
1849 In one\-liner form:
1850 .PP
1851 .Vb 1
1852 \& perl \-ne \*(Aqtr/n\-za\-mN\-ZA\-M/a\-zA\-Z/;print\*(Aq
1853 .Ve
1854 .SH "Hashing order and checksums"
1855 .IX Header "Hashing order and checksums"
1856 Perl deliberately randomizes hash order for security purposes on both
1857 ASCII and EBCDIC platforms.
1858 .PP
1859 EBCDIC checksums will differ for the same file translated into ASCII
1860 and vice versa.
1861 .SH "I18N AND L10N"
1862 .IX Header "I18N AND L10N"
1863 Internationalization (I18N) and localization (L10N) are supported at least
1864 in principle even on EBCDIC platforms. The details are system\-dependent
1865 and discussed under the "OS ISSUES" section below.
1866 .SH "MULTI\-OCTET CHARACTER SETS"
1867 .IX Header "MULTI-OCTET CHARACTER SETS"
1868 Perl works with UTF\-EBCDIC, a multi\-byte encoding. In Perls earlier
1869 than v5.22, there may be various bugs in this regard.
1870 .PP
1871 Legacy multi byte EBCDIC code pages XXX.
1872 .SH "OS ISSUES"
1873 .IX Header "OS ISSUES"
1874 There may be a few system\-dependent issues
1875 of concern to EBCDIC Perl programmers.
1876 .SS OS/400
1877 .IX Subsection "OS/400"
1878 .IP PASE 8
1879 .IX Item "PASE"
1880 The PASE environment is a runtime environment for OS/400 that can run
1881 executables built for PowerPC AIX in OS/400; see perlos400. PASE
1882 is ASCII\-based, not EBCDIC\-based as the ILE.
1883 .IP "IFS access" 8
1884 .IX Item "IFS access"
1885 XXX.
1886 .SS "OS/390, z/OS"
1887 .IX Subsection "OS/390, z/OS"
1888 Perl runs under Unix Systems Services or USS.
1889 .ie n .IP """sigaction""" 8
1890 .el .IP \f(CWsigaction\fR 8
1891 .IX Item "sigaction"
1892 \&\f(CW\*(C`SA_SIGINFO\*(C'\fR can have segmentation faults.
1893 .ie n .IP """chcp""" 8
1894 .el .IP \f(CWchcp\fR 8
1895 .IX Item "chcp"
1896 \&\fBchcp\fR is supported as a shell utility for displaying and changing
1897 one\*(Aqs code page. See also \fBchcp\fR\|(1).
1898 .IP "dataset access" 8
1899 .IX Item "dataset access"
1900 For sequential data set access try:
1901 .Sp
1902 .Vb 1
1903 \& my @ds_records = \`cat //DSNAME\`;
1904 .Ve
1905 .Sp
1906 or:
1907 .Sp
1908 .Vb 1
1909 \& my @ds_records = \`cat //\*(AqHLQ.DSNAME\*(Aq\`;
1910 .Ve
1911 .Sp
1912 See also the OS390::Stdio module on CPAN.
1913 .ie n .IP """iconv""" 8
1914 .el .IP \f(CWiconv\fR 8
1915 .IX Item "iconv"
1916 \&\fBiconv\fR is supported as both a shell utility and a C RTL routine.
1917 See also the \fBiconv\fR\|(1) and \fBiconv\fR\|(3) manual pages.
1918 .IP locales 8
1919 .IX Item "locales"
1920 Locales are supported. There may be glitches when a locale is another
1921 EBCDIC code page which has some of the
1922 code\-page variant characters in other
1923 positions.
1924 .Sp
1925 There aren\*(Aqt currently any real UTF\-8 locales, even though some locale
1926 names contain the string "UTF\-8".
1927 .Sp
1928 See perllocale for information on locales. The L10N files
1929 are in \fI/usr/nls/locale\fR. \f(CW$Config{d_setlocale}\fR is \f(CW\*(Aqdefine\*(Aq\fR on
1930 OS/390 or z/OS.
1931 .SS POSIX\-BC?
1932 .IX Subsection "POSIX-BC?"
1933 XXX.
1934 .SH BUGS
1935 .IX Header "BUGS"
1936 .IP \(bu 4
1937 Not all shells will allow multiple \f(CW\*(C`\-e\*(C'\fR string arguments to perl to
1938 be concatenated together properly as recipes in this document
1939 0, 2, 4, 5, and 6 might
1940 seem to imply.
1941 .IP \(bu 4
1942 There are a significant number of test failures in the CPAN modules
1943 shipped with Perl v5.22 and 5.24. These are only in modules not primarily
1944 maintained by Perl 5 porters. Some of these are failures in the tests
1945 only: they don\*(Aqt realize that it is proper to get different results on
1946 EBCDIC platforms. And some of the failures are real bugs. If you
1947 compile and do a \f(CW\*(C`make test\*(C'\fR on Perl, all tests on the \f(CW\*(C`/cpan\*(C'\fR
1948 directory are skipped.
1949 .Sp
1950 Encode partially works.
1951 .IP \(bu 4
1952 In earlier Perl versions, when byte and character data were
1953 concatenated, the new string was sometimes created by
1954 decoding the byte strings as \fIISO 8859\-1 (Latin\-1)\fR, even if the
1955 old Unicode string used EBCDIC.
1956 .SH "SEE ALSO"
1957 .IX Header "SEE ALSO"
1958 perllocale, perlfunc, perlunicode, utf8.
1959 .SH REFERENCES
1960 .IX Header "REFERENCES"
1961 <http://std.dkuug.dk/i18n/charmaps>
1962 .PP
1963 <https://www.unicode.org/>
1964 .PP
1965 <https://www.unicode.org/reports/tr16/>
1966 .PP
1967 <https://www.sr\-ix.com/Archive/CharCodeHist/index.html>
1968 \&\fBASCII: American Standard Code for Information Infiltration\fR Tom Jennings,
1969 September 1999.
1970 .PP
1971 \&\fBThe Unicode Standard, Version 3.0\fR The Unicode Consortium, Lisa Moore ed.,
1972 ISBN 0\-201\-61633\-5, Addison Wesley Developers Press, February 2000.
1973 .PP
1974 \&\fBCDRA: IBM \- Character Data Representation Architecture \-
1975 Reference and Registry\fR, IBM SC09\-2190\-00, December 1996.
1976 .PP
1977 "Demystifying Character Sets", Andrea Vine, Multilingual Computing
1978 & Technology, \fB#26 Vol. 10 Issue 4\fR, August/September 1999;
1979 ISSN 1523\-0309; Multilingual Computing Inc. Sandpoint ID, USA.
1980 .PP
1981 \&\fBCodes, Ciphers, and Other Cryptic and Clandestine Communication\fR
1982 Fred B. Wrixon, ISBN 1\-57912\-040\-7, Black Dog & Leventhal Publishers,
1983 1998.
1984 .PP
1985 <http://www.bobbemer.com/P\-BIT.HTM>
1986 \&\fBIBM \- EBCDIC and the P\-bit; The biggest Computer Goof Ever\fR Robert Bemer.
1987 .SH HISTORY
1988 .IX Header "HISTORY"
1989 15 April 2001: added UTF\-8 and UTF\-EBCDIC to main table, pvhp.
1990 .SH AUTHOR
1991 .IX Header "AUTHOR"
1992 Peter Prymmer [email protected] wrote this in 1999 and 2000
1993 with CCSID 0819 and 0037 help from Chris Leach and
1994 André Pirard [email protected] as well as POSIX\-BC
1995 help from Thomas Dorner [email protected].
1996 Thanks also to Vickie Cooper, Philip Newton, William Raffloer, and
1997 Joe Smith. Trademarks, registered trademarks, service marks and
1998 registered service marks used in this document are the property of
1999 their respective owners.
2000 .PP
2001 Now maintained by Perl5 Porters.