xref: /netbsd-src/bin/dd/conv_tab.c (revision 4b30c543a0b21e3ba94f2c569e9a82b4fdb2075f)
1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Keith Muller of the University of California, San Diego and Lance
7  * Visser of Convex Computer Corporation.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed by the University of
20  *	California, Berkeley and its contributors.
21  * 4. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  */
37 
38 #ifndef lint
39 /*static char sccsid[] = "from: @(#)conv_tab.c	5.3 (Berkeley) 7/29/91";*/
40 static char rcsid[] = "$Id: conv_tab.c,v 1.2 1993/08/01 19:00:09 mycroft Exp $";
41 #endif /* not lint */
42 
43 #include <sys/types.h>
44 
45 /*
46  * There are currently eight tables:
47  *
48  *	lower-case	-> upper-case			conv=upper
49  *	upper-case	-> lower-case			conv=lower
50  *
51  *	ebcdic		-> ascii	32V		conv=oldascii
52  *	ascii		-> ebcdic	32V		conv=oldebcdic
53  *	ascii		-> ibm ebcdic	32V		conv=oldibm
54  *
55  *	ebcdic		-> ascii	POSIX/S5	conv=ascii
56  *	ascii		-> ebcdic	POSIX/S5	conv=ebcdic
57  *	ascii		-> ibm ebcdic	POSIX/S5	conv=ibm
58  *
59  * Other tables are built from these if multiple conversions are being
60  * done.
61  *
62  * Tables used for conversions to/from IBM and EBCDIC to support an extension
63  * to POSIX P1003.2/D11. The tables referencing POSIX contain data extracted
64  * from tables 4-3 and 4-4 in P1003.2/Draft 11.  The historic tables were
65  * constructed by running against a file with all possible byte values.
66  *
67  * More information can be obtained in "Correspondences of 8-Bit and Hollerith
68  * Codes for Computer Environments-A USASI Tutorial", Communications of the
69  * ACM, Volume 11, Number 11, November 1968, pp. 783-789.
70  */
71 
72 /* Lower-case to upper-case */
73 u_char l2u[] = {
74 	0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007,		/* 0000 */
75 	0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017,		/* 0010 */
76 	0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027,		/* 0020 */
77 	0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037,		/* 0030 */
78 	0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047,		/* 0040 */
79 	0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057,		/* 0050 */
80 	0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067,		/* 0060 */
81 	0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077,		/* 0070 */
82 	0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107,		/* 0100 */
83 	0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,		/* 0110 */
84 	0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,		/* 0120 */
85 	0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137,		/* 0130 */
86 	0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107,		/* 0140 */
87 	0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,		/* 0150 */
88 	0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127,		/* 0160 */
89 	0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177,		/* 0170 */
90 	0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,		/* 0200 */
91 	0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,		/* 0210 */
92 	0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,		/* 0220 */
93 	0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,		/* 0230 */
94 	0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,		/* 0240 */
95 	0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,		/* 0250 */
96 	0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,		/* 0260 */
97 	0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,		/* 0270 */
98 	0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,		/* 0300 */
99 	0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,		/* 0310 */
100 	0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,		/* 0320 */
101 	0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,		/* 0330 */
102 	0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,		/* 0340 */
103 	0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,		/* 0350 */
104 	0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,		/* 0360 */
105 	0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377,		/* 0370 */
106 };
107 
108 /* Upper-case to lower-case */
109 u_char u2l[] = {
110 	0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007,		/* 0000 */
111 	0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017,		/* 0010 */
112 	0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027,		/* 0020 */
113 	0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037,		/* 0030 */
114 	0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047,		/* 0040 */
115 	0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057,		/* 0050 */
116 	0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067,		/* 0060 */
117 	0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077,		/* 0070 */
118 	0100, 0141, 0142, 0143, 0144, 0145, 0146, 0147,		/* 0100 */
119 	0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,		/* 0110 */
120 	0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167,		/* 0120 */
121 	0170, 0171, 0172, 0133, 0134, 0135, 0136, 0137,		/* 0130 */
122 	0140, 0141, 0142, 0143, 0144, 0145, 0146, 0147,		/* 0140 */
123 	0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,		/* 0150 */
124 	0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167,		/* 0160 */
125 	0170, 0171, 0172, 0173, 0174, 0175, 0176, 0177,		/* 0170 */
126 	0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,		/* 0200 */
127 	0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,		/* 0210 */
128 	0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,		/* 0220 */
129 	0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,		/* 0230 */
130 	0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,		/* 0240 */
131 	0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,		/* 0250 */
132 	0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,		/* 0260 */
133 	0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,		/* 0270 */
134 	0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,		/* 0300 */
135 	0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,		/* 0310 */
136 	0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,		/* 0320 */
137 	0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,		/* 0330 */
138 	0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,		/* 0340 */
139 	0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,		/* 0350 */
140 	0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,		/* 0360 */
141 	0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377,		/* 0370 */
142 };
143 
144 /* EBCDIC to ASCII -- 32V compatible. */
145 u_char e2a_32V[] = {
146 	0000, 0001, 0002, 0003, 0234, 0011, 0206, 0177,		/* 0000 */
147 	0227, 0215, 0216, 0013, 0014, 0015, 0016, 0017,		/* 0010 */
148 	0020, 0021, 0022, 0023, 0235, 0205, 0010, 0207,		/* 0020 */
149 	0030, 0031, 0222, 0217, 0034, 0035, 0036, 0037,		/* 0030 */
150 	0200, 0201, 0202, 0203, 0204, 0012, 0027, 0033,		/* 0040 */
151 	0210, 0211, 0212, 0213, 0214, 0005, 0006, 0007,		/* 0050 */
152 	0220, 0221, 0026, 0223, 0224, 0225, 0226, 0004,		/* 0060 */
153 	0230, 0231, 0232, 0233, 0024, 0025, 0236, 0032,		/* 0070 */
154 	0040, 0240, 0241, 0242, 0243, 0244, 0245, 0246,		/* 0100 */
155 	0247, 0250, 0133, 0056, 0074, 0050, 0053, 0041,		/* 0110 */
156 	0046, 0251, 0252, 0253, 0254, 0255, 0256, 0257,		/* 0120 */
157 	0260, 0261, 0135, 0044, 0052, 0051, 0073, 0136,		/* 0130 */
158 	0055, 0057, 0262, 0263, 0264, 0265, 0266, 0267,		/* 0140 */
159 	0270, 0271, 0174, 0054, 0045, 0137, 0076, 0077,		/* 0150 */
160 	0272, 0273, 0274, 0275, 0276, 0277, 0300, 0301,		/* 0160 */
161 	0302, 0140, 0072, 0043, 0100, 0047, 0075, 0042,		/* 0170 */
162 	0303, 0141, 0142, 0143, 0144, 0145, 0146, 0147,		/* 0200 */
163 	0150, 0151, 0304, 0305, 0306, 0307, 0310, 0311,		/* 0210 */
164 	0312, 0152, 0153, 0154, 0155, 0156, 0157, 0160,		/* 0220 */
165 	0161, 0162, 0313, 0314, 0315, 0316, 0317, 0320,		/* 0230 */
166 	0321, 0176, 0163, 0164, 0165, 0166, 0167, 0170,		/* 0240 */
167 	0171, 0172, 0322, 0323, 0324, 0325, 0326, 0327,		/* 0250 */
168 	0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,		/* 0260 */
169 	0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,		/* 0270 */
170 	0173, 0101, 0102, 0103, 0104, 0105, 0106, 0107,		/* 0300 */
171 	0110, 0111, 0350, 0351, 0352, 0353, 0354, 0355,		/* 0310 */
172 	0175, 0112, 0113, 0114, 0115, 0116, 0117, 0120,		/* 0320 */
173 	0121, 0122, 0356, 0357, 0360, 0361, 0362, 0363,		/* 0330 */
174 	0134, 0237, 0123, 0124, 0125, 0126, 0127, 0130,		/* 0340 */
175 	0131, 0132, 0364, 0365, 0366, 0367, 0370, 0371,		/* 0350 */
176 	0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067,		/* 0360 */
177 	0070, 0071, 0372, 0373, 0374, 0375, 0376, 0377,		/* 0370 */
178 };
179 
180 /* ASCII to EBCDIC -- 32V compatible. */
181 u_char a2e_32V[] = {
182 	0000, 0001, 0002, 0003, 0067, 0055, 0056, 0057,		/* 0000 */
183 	0026, 0005, 0045, 0013, 0014, 0015, 0016, 0017,		/* 0010 */
184 	0020, 0021, 0022, 0023, 0074, 0075, 0062, 0046,		/* 0020 */
185 	0030, 0031, 0077, 0047, 0034, 0035, 0036, 0037,		/* 0030 */
186 	0100, 0117, 0177, 0173, 0133, 0154, 0120, 0175,		/* 0040 */
187 	0115, 0135, 0134, 0116, 0153, 0140, 0113, 0141,		/* 0050 */
188 	0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,		/* 0060 */
189 	0370, 0371, 0172, 0136, 0114, 0176, 0156, 0157,		/* 0070 */
190 	0174, 0301, 0302, 0303, 0304, 0305, 0306, 0307,		/* 0100 */
191 	0310, 0311, 0321, 0322, 0323, 0324, 0325, 0326,		/* 0110 */
192 	0327, 0330, 0331, 0342, 0343, 0344, 0345, 0346,		/* 0120 */
193 	0347, 0350, 0351, 0112, 0340, 0132, 0137, 0155,		/* 0130 */
194 	0171, 0201, 0202, 0203, 0204, 0205, 0206, 0207,		/* 0140 */
195 	0210, 0211, 0221, 0222, 0223, 0224, 0225, 0226,		/* 0150 */
196 	0227, 0230, 0231, 0242, 0243, 0244, 0245, 0246,		/* 0160 */
197 	0247, 0250, 0251, 0300, 0152, 0320, 0241, 0007,		/* 0170 */
198 	0040, 0041, 0042, 0043, 0044, 0025, 0006, 0027,		/* 0200 */
199 	0050, 0051, 0052, 0053, 0054, 0011, 0012, 0033,		/* 0210 */
200 	0060, 0061, 0032, 0063, 0064, 0065, 0066, 0010,		/* 0220 */
201 	0070, 0071, 0072, 0073, 0004, 0024, 0076, 0341,		/* 0230 */
202 	0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110,		/* 0240 */
203 	0111, 0121, 0122, 0123, 0124, 0125, 0126, 0127,		/* 0250 */
204 	0130, 0131, 0142, 0143, 0144, 0145, 0146, 0147,		/* 0260 */
205 	0150, 0151, 0160, 0161, 0162, 0163, 0164, 0165,		/* 0270 */
206 	0166, 0167, 0170, 0200, 0212, 0213, 0214, 0215,		/* 0300 */
207 	0216, 0217, 0220, 0232, 0233, 0234, 0235, 0236,		/* 0310 */
208 	0237, 0240, 0252, 0253, 0254, 0255, 0256, 0257,		/* 0320 */
209 	0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,		/* 0330 */
210 	0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,		/* 0340 */
211 	0312, 0313, 0314, 0315, 0316, 0317, 0332, 0333,		/* 0350 */
212 	0334, 0335, 0336, 0337, 0352, 0353, 0354, 0355,		/* 0360 */
213 	0356, 0357, 0372, 0373, 0374, 0375, 0376, 0377,		/* 0370 */
214 };
215 
216 /* ASCII to IBM EBCDIC -- 32V compatible. */
217 u_char a2ibm_32V[] = {
218 	0000, 0001, 0002, 0003, 0067, 0055, 0056, 0057,		/* 0000 */
219 	0026, 0005, 0045, 0013, 0014, 0015, 0016, 0017,		/* 0010 */
220 	0020, 0021, 0022, 0023, 0074, 0075, 0062, 0046,		/* 0020 */
221 	0030, 0031, 0077, 0047, 0034, 0035, 0036, 0037,		/* 0030 */
222 	0100, 0132, 0177, 0173, 0133, 0154, 0120, 0175,		/* 0040 */
223 	0115, 0135, 0134, 0116, 0153, 0140, 0113, 0141,		/* 0050 */
224 	0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,		/* 0060 */
225 	0370, 0371, 0172, 0136, 0114, 0176, 0156, 0157,		/* 0070 */
226 	0174, 0301, 0302, 0303, 0304, 0305, 0306, 0307,		/* 0100 */
227 	0310, 0311, 0321, 0322, 0323, 0324, 0325, 0326,		/* 0110 */
228 	0327, 0330, 0331, 0342, 0343, 0344, 0345, 0346,		/* 0120 */
229 	0347, 0350, 0351, 0255, 0340, 0275, 0137, 0155,		/* 0130 */
230 	0171, 0201, 0202, 0203, 0204, 0205, 0206, 0207,		/* 0140 */
231 	0210, 0211, 0221, 0222, 0223, 0224, 0225, 0226,		/* 0150 */
232 	0227, 0230, 0231, 0242, 0243, 0244, 0245, 0246,		/* 0160 */
233 	0247, 0250, 0251, 0300, 0117, 0320, 0241, 0007,		/* 0170 */
234 	0040, 0041, 0042, 0043, 0044, 0025, 0006, 0027,		/* 0200 */
235 	0050, 0051, 0052, 0053, 0054, 0011, 0012, 0033,		/* 0210 */
236 	0060, 0061, 0032, 0063, 0064, 0065, 0066, 0010,		/* 0220 */
237 	0070, 0071, 0072, 0073, 0004, 0024, 0076, 0341,		/* 0230 */
238 	0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110,		/* 0240 */
239 	0111, 0121, 0122, 0123, 0124, 0125, 0126, 0127,		/* 0250 */
240 	0130, 0131, 0142, 0143, 0144, 0145, 0146, 0147,		/* 0260 */
241 	0150, 0151, 0160, 0161, 0162, 0163, 0164, 0165,		/* 0270 */
242 	0166, 0167, 0170, 0200, 0212, 0213, 0214, 0215,		/* 0300 */
243 	0216, 0217, 0220, 0232, 0233, 0234, 0235, 0236,		/* 0310 */
244 	0237, 0240, 0252, 0253, 0254, 0255, 0256, 0257,		/* 0320 */
245 	0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,		/* 0330 */
246 	0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,		/* 0340 */
247 	0312, 0313, 0314, 0315, 0316, 0317, 0332, 0333,		/* 0350 */
248 	0334, 0335, 0336, 0337, 0352, 0353, 0354, 0355,		/* 0360 */
249 	0356, 0357, 0372, 0373, 0374, 0375, 0376, 0377,		/* 0370 */
250 };
251 
252 /* EBCDIC to ASCII -- POSIX and System V compatible. */
253 u_char e2a_POSIX[] = {
254 	0000, 0001, 0002, 0003, 0234, 0011, 0206, 0177,		/* 0000 */
255 	0227, 0215, 0216, 0013, 0014, 0015, 0016, 0017,		/* 0010 */
256 	0020, 0021, 0022, 0023, 0235, 0205, 0010, 0207,		/* 0020 */
257 	0030, 0031, 0222, 0217, 0034, 0035, 0036, 0037,		/* 0030 */
258 	0200, 0201, 0202, 0203, 0204, 0012, 0027, 0033,		/* 0040 */
259 	0210, 0211, 0212, 0213, 0214, 0005, 0006, 0007,		/* 0050 */
260 	0220, 0221, 0026, 0223, 0224, 0225, 0226, 0004,		/* 0060 */
261 	0230, 0231, 0232, 0233, 0024, 0025, 0236, 0032,		/* 0070 */
262 	0040, 0240, 0241, 0242, 0243, 0244, 0245, 0246,		/* 0100 */
263 	0247, 0250, 0325, 0056, 0074, 0050, 0053, 0174,		/* 0110 */
264 	0046, 0251, 0252, 0253, 0254, 0255, 0256, 0257,		/* 0120 */
265 	0260, 0261, 0041, 0044, 0052, 0051, 0073, 0176,		/* 0130 */
266 	0055, 0057, 0262, 0263, 0264, 0265, 0266, 0267,		/* 0140 */
267 	0270, 0271, 0313, 0054, 0045, 0137, 0076, 0077,		/* 0150 */
268 	0272, 0273, 0274, 0275, 0276, 0277, 0300, 0301,		/* 0160 */
269 	0302, 0140, 0072, 0043, 0100, 0047, 0075, 0042,		/* 0170 */
270 	0303, 0141, 0142, 0143, 0144, 0145, 0146, 0147,		/* 0200 */
271 	0150, 0151, 0304, 0305, 0306, 0307, 0310, 0311,		/* 0210 */
272 	0312, 0152, 0153, 0154, 0155, 0156, 0157, 0160,		/* 0220 */
273 	0161, 0162, 0136, 0314, 0315, 0316, 0317, 0320,		/* 0230 */
274 	0321, 0345, 0163, 0164, 0165, 0166, 0167, 0170,		/* 0240 */
275 	0171, 0172, 0322, 0323, 0324, 0133, 0326, 0327,		/* 0250 */
276 	0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,		/* 0260 */
277 	0340, 0341, 0342, 0343, 0344, 0135, 0346, 0347,		/* 0270 */
278 	0173, 0101, 0102, 0103, 0104, 0105, 0106, 0107,		/* 0300 */
279 	0110, 0111, 0350, 0351, 0352, 0353, 0354, 0355,		/* 0310 */
280 	0175, 0112, 0113, 0114, 0115, 0116, 0117, 0120,		/* 0320 */
281 	0121, 0122, 0356, 0357, 0360, 0361, 0362, 0363,		/* 0330 */
282 	0134, 0237, 0123, 0124, 0125, 0126, 0127, 0130,		/* 0340 */
283 	0131, 0132, 0364, 0365, 0366, 0367, 0370, 0371,		/* 0350 */
284 	0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067,		/* 0360 */
285 	0070, 0071, 0372, 0373, 0374, 0375, 0376, 0377,		/* 0370 */
286 };
287 
288 /* ASCII to EBCDIC -- POSIX and System V compatible. */
289 u_char a2e_POSIX[] = {
290 	0000, 0001, 0002, 0003, 0067, 0055, 0056, 0057,		/* 0000 */
291 	0026, 0005, 0045, 0013, 0014, 0015, 0016, 0017,		/* 0010 */
292 	0020, 0021, 0022, 0023, 0074, 0075, 0062, 0046,		/* 0020 */
293 	0030, 0031, 0077, 0047, 0034, 0035, 0036, 0037,		/* 0030 */
294 	0100, 0132, 0177, 0173, 0133, 0154, 0120, 0175,		/* 0040 */
295 	0115, 0135, 0134, 0116, 0153, 0140, 0113, 0141,		/* 0050 */
296 	0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,		/* 0060 */
297 	0370, 0371, 0172, 0136, 0114, 0176, 0156, 0157,		/* 0070 */
298 	0174, 0301, 0302, 0303, 0304, 0305, 0306, 0307,		/* 0100 */
299 	0310, 0311, 0321, 0322, 0323, 0324, 0325, 0326,		/* 0110 */
300 	0327, 0330, 0331, 0342, 0343, 0344, 0345, 0346,		/* 0120 */
301 	0347, 0350, 0351, 0255, 0340, 0275, 0232, 0155,		/* 0130 */
302 	0171, 0201, 0202, 0203, 0204, 0205, 0206, 0207,		/* 0140 */
303 	0210, 0211, 0221, 0222, 0223, 0224, 0225, 0226,		/* 0150 */
304 	0227, 0230, 0231, 0242, 0243, 0244, 0245, 0246,		/* 0160 */
305 	0247, 0250, 0251, 0300, 0117, 0320, 0137, 0007,		/* 0170 */
306 	0040, 0041, 0042, 0043, 0044, 0025, 0006, 0027,		/* 0200 */
307 	0050, 0051, 0052, 0053, 0054, 0011, 0012, 0033,		/* 0210 */
308 	0060, 0061, 0032, 0063, 0064, 0065, 0066, 0010,		/* 0220 */
309 	0070, 0071, 0072, 0073, 0004, 0024, 0076, 0341,		/* 0230 */
310 	0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110,		/* 0240 */
311 	0111, 0121, 0122, 0123, 0124, 0125, 0126, 0127,		/* 0250 */
312 	0130, 0131, 0142, 0143, 0144, 0145, 0146, 0147,		/* 0260 */
313 	0150, 0151, 0160, 0161, 0162, 0163, 0164, 0165,		/* 0270 */
314 	0166, 0167, 0170, 0200, 0212, 0213, 0214, 0215,		/* 0300 */
315 	0216, 0217, 0220, 0152, 0233, 0234, 0235, 0236,		/* 0310 */
316 	0237, 0240, 0252, 0253, 0254, 0112, 0256, 0257,		/* 0320 */
317 	0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,		/* 0330 */
318 	0270, 0271, 0272, 0273, 0274, 0241, 0276, 0277,		/* 0340 */
319 	0312, 0313, 0314, 0315, 0316, 0317, 0332, 0333,		/* 0350 */
320 	0334, 0335, 0336, 0337, 0352, 0353, 0354, 0355,		/* 0360 */
321 	0356, 0357, 0372, 0373, 0374, 0375, 0376, 0377,		/* 0370 */
322 };
323 
324 /* ASCII to IBM EBCDIC -- POSIX and System V compatible. */
325 u_char a2ibm_POSIX[] = {
326 	0000, 0001, 0002, 0003, 0067, 0055, 0056, 0057,		/* 0000 */
327 	0026, 0005, 0045, 0013, 0014, 0015, 0016, 0017,		/* 0010 */
328 	0020, 0021, 0022, 0023, 0074, 0075, 0062, 0046,		/* 0020 */
329 	0030, 0031, 0077, 0047, 0034, 0035, 0036, 0037,		/* 0030 */
330 	0100, 0132, 0177, 0173, 0133, 0154, 0120, 0175,		/* 0040 */
331 	0115, 0135, 0134, 0116, 0153, 0140, 0113, 0141,		/* 0050 */
332 	0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,		/* 0060 */
333 	0370, 0371, 0172, 0136, 0114, 0176, 0156, 0157,		/* 0070 */
334 	0174, 0301, 0302, 0303, 0304, 0305, 0306, 0307,		/* 0100 */
335 	0310, 0311, 0321, 0322, 0323, 0324, 0325, 0326,		/* 0110 */
336 	0327, 0330, 0331, 0342, 0343, 0344, 0345, 0346,		/* 0120 */
337 	0347, 0350, 0351, 0255, 0340, 0275, 0137, 0155,		/* 0130 */
338 	0171, 0201, 0202, 0203, 0204, 0205, 0206, 0207,		/* 0140 */
339 	0210, 0211, 0221, 0222, 0223, 0224, 0225, 0226,		/* 0150 */
340 	0227, 0230, 0231, 0242, 0243, 0244, 0245, 0246,		/* 0160 */
341 	0247, 0250, 0251, 0300, 0117, 0320, 0241, 0007,		/* 0170 */
342 	0040, 0041, 0042, 0043, 0044, 0025, 0006, 0027,		/* 0200 */
343 	0050, 0051, 0052, 0053, 0054, 0011, 0012, 0033,		/* 0210 */
344 	0060, 0061, 0032, 0063, 0064, 0065, 0066, 0010,		/* 0220 */
345 	0070, 0071, 0072, 0073, 0004, 0024, 0076, 0341,		/* 0230 */
346 	0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110,		/* 0240 */
347 	0111, 0121, 0122, 0123, 0124, 0125, 0126, 0127,		/* 0250 */
348 	0130, 0131, 0142, 0143, 0144, 0145, 0146, 0147,		/* 0260 */
349 	0150, 0151, 0160, 0161, 0162, 0163, 0164, 0165,		/* 0270 */
350 	0166, 0167, 0170, 0200, 0212, 0213, 0214, 0215,		/* 0300 */
351 	0216, 0217, 0220, 0232, 0233, 0234, 0235, 0236,		/* 0310 */
352 	0237, 0240, 0252, 0253, 0254, 0255, 0256, 0257,		/* 0320 */
353 	0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,		/* 0330 */
354 	0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,		/* 0340 */
355 	0312, 0313, 0314, 0315, 0316, 0317, 0332, 0333,		/* 0350 */
356 	0334, 0335, 0336, 0337, 0352, 0353, 0354, 0355,		/* 0360 */
357 	0356, 0357, 0372, 0373, 0374, 0375, 0376, 0377,		/* 0370 */
358 };
359