Rizin
unix-like reverse engineering framework and cli tools
ebcdic.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 Billow <billow.fun@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "rz_util/rz_ebcdic.h"
5 #include "rz_util/rz_assert.h"
6 
22 static const RzRune ibm037_to_uni[256] = {
23  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
24  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
25  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
26  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
27  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
28  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
29  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
30  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
31  0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 0x40-0x47 */
32  0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* 0x48-0x4f */
33  0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 0x50-0x57 */
34  0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac, /* 0x58-0x5f */
35  0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 0x60-0x67 */
36  0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* 0x68-0x6f */
37  0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 0x70-0x77 */
38  0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* 0x78-0x7f */
39  0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x80-0x87 */
40  0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* 0x88-0x8f */
41  0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 0x90-0x97 */
42  0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* 0x98-0x9f */
43  0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* 0xa0-0xa7 */
44  0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /* 0xa8-0xaf */
45  0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* 0xb0-0xb7 */
46  0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7, /* 0xb8-0xbf */
47  0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0xc0-0xc7 */
48  0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* 0xc8-0xcf */
49  0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* 0xd0-0xd7 */
50  0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* 0xd8-0xdf */
51  0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* 0xe0-0xe7 */
52  0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* 0xe8-0xef */
53  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0xf0-0xf7 */
54  0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x7f, /* 0xf8-0xff */
55 };
56 
57 static const ut8 ibm037_from_uni[256] = {
58  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
59  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
60  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
61  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
62  0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 0x20-0x27 */
63  0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* 0x28-0x2f */
64  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x30-0x37 */
65  0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0x38-0x3f */
66  0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x40-0x47 */
67  0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* 0x48-0x4f */
68  0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 0x50-0x57 */
69  0xe7, 0xe8, 0xe9, 0xba, 0xe0, 0xbb, 0xb0, 0x6d, /* 0x58-0x5f */
70  0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x60-0x67 */
71  0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 0x68-0x6f */
72  0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 0x70-0x77 */
73  0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0xff, /* 0x78-0x7f */
74  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
75  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
76  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
77  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
78  0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* 0xa0-0xa7 */
79  0xbd, 0xb4, 0x9a, 0x8a, 0x5f, 0xca, 0xaf, 0xbc, /* 0xa8-0xaf */
80  0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* 0xb0-0xb7 */
81  0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* 0xb8-0xbf */
82  0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* 0xc0-0xc7 */
83  0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* 0xc8-0xcf */
84  0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* 0xd0-0xd7 */
85  0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0xae, 0x59, /* 0xd8-0xdf */
86  0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* 0xe0-0xe7 */
87  0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* 0xe8-0xef */
88  0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* 0xf0-0xf7 */
89  0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf, /* 0xf8-0xff */
90 };
91 
92 static const RzRune ibm290_to_uni[256] = {
93  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
94  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
95  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
96  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
97  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
98  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
99  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
100  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
101  0x20, 0x3002, 0x300c, 0x300d, 0x3001, 0x30fb, 0x30f2, 0x30a1, /* 0x40-0x47 */
102  0x30a3, 0x30a5, 0xa3, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* 0x48-0x4f */
103  0x26, 0x30a7, 0x30a9, 0x30e3, 0x30e5, 0x30e7, 0x30c3, 0x00, /* 0x50-0x57 */
104  0x30fc, 0x00, 0x21, 0xa5, 0x2a, 0x29, 0x3b, 0xac, /* 0x58-0x5f */
105  0x2d, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
106  0x00, 0x00, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* 0x68-0x6f */
107  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
108  0x00, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* 0x78-0x7f */
109  0x00, 0x30a2, 0x30a4, 0x30a6, 0x30a8, 0x30aa, 0x30ab, 0x30ad, /* 0x80-0x87 */
110  0x30af, 0x30b1, 0x30b3, 0x00, 0x30b5, 0x30b7, 0x30b9, 0x30bb, /* 0x88-0x8f */
111  0x30bd, 0x30bf, 0x30c1, 0x30c4, 0x30c6, 0x30c8, 0x30ca, 0x30cb, /* 0x90-0x97 */
112  0x30cc, 0x30cd, 0x30ce, 0x00, 0x00, 0x30cf, 0x30d2, 0x30d5, /* 0x98-0x9f */
113  0x00, 0xaf, 0x30d8, 0x30db, 0x30de, 0x30df, 0x30e0, 0x30e1, /* 0xa0-0xa7 */
114  0x30e2, 0x30e4, 0x30e6, 0x00, 0x30e8, 0x30e9, 0x30ea, 0x30eb, /* 0xa8-0xaf */
115  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
116  0x00, 0x00, 0x30ec, 0x30ed, 0x30ef, 0x30f3, 0x309b, 0x309c, /* 0xb8-0xbf */
117  0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0xc0-0xc7 */
118  0x48, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
119  0x00, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* 0xd0-0xd7 */
120  0x51, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
121  0x24, 0x00, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* 0xe0-0xe7 */
122  0x59, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
123  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0xf0-0xf7 */
124  0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, /* 0xf8-0xff */
125 };
126 
127 static const ut8 ibm290_page00[256] = {
128  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
129  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
130  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
131  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
132  0x40, 0x5a, 0x7f, 0x7b, 0xe0, 0x6c, 0x50, 0x7d, /* 0x20-0x27 */
133  0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* 0x28-0x2f */
134  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x30-0x37 */
135  0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0x38-0x3f */
136  0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x40-0x47 */
137  0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* 0x48-0x4f */
138  0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 0x50-0x57 */
139  0xe7, 0xe8, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x6d, /* 0x58-0x5f */
140  0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
141  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
142  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
143  0x00, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0xff, /* 0x78-0x7f */
144  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
145  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
146  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
147  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
148  0x00, 0x00, 0x00, 0x4a, 0x00, 0x5b, 0x6a, 0x00, /* 0xa0-0xa7 */
149  0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0xa1, /* 0xa8-0xaf */
150  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
151  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
152  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
153  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
154  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
155  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
156  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
157  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
158  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
159  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */
160 };
161 
162 static const ut8 ibm290_page30[256] = {
163  [0x01] = 0x44,
164  [0x02] = 0x41,
165  [0x0c] = 0x42,
166  [0x0d] = 0x43,
167  [0xfb] = 0x45,
168  [0xf2] = 0x46,
169  [0xa1] = 0x47,
170  [0xa3] = 0x48,
171  [0xa5] = 0x49,
172  [0xa7] = 0x51,
173  [0xa9] = 0x52,
174  [0xe3] = 0x53,
175  [0xe5] = 0x54,
176  [0xe7] = 0x55,
177  [0xc3] = 0x56,
178  [0xfc] = 0x58,
179  [0xa2] = 0x81,
180  [0xa4] = 0x82,
181  [0xa6] = 0x83,
182  [0xa8] = 0x84,
183  [0xaa] = 0x85,
184  [0xab] = 0x86,
185  [0xad] = 0x87,
186  [0xaf] = 0x88,
187  [0xb1] = 0x89,
188  [0xb3] = 0x8a,
189  [0xb5] = 0x8c,
190  [0xb7] = 0x8d,
191  [0xb9] = 0x8e,
192  [0xbb] = 0x8f,
193  [0xbd] = 0x90,
194  [0xbf] = 0x91,
195  [0xc1] = 0x92,
196  [0xc4] = 0x93,
197  [0xc6] = 0x94,
198  [0xc8] = 0x95,
199  [0xca] = 0x96,
200  [0xcb] = 0x97,
201  [0xcc] = 0x98,
202  [0xcd] = 0x99,
203  [0xce] = 0x9a,
204  [0xcf] = 0x9d,
205  [0xd2] = 0x9e,
206  [0xd5] = 0x9f,
207  [0xd8] = 0xa2,
208  [0xdb] = 0xa3,
209  [0xde] = 0xa4,
210  [0xdf] = 0xa5,
211  [0xe0] = 0xa6,
212  [0xe1] = 0xa7,
213  [0xe2] = 0xa8,
214  [0xe4] = 0xa9,
215  [0xe6] = 0xaa,
216  [0xe8] = 0xac,
217  [0xe9] = 0xad,
218  [0xea] = 0xae,
219  [0xeb] = 0xaf,
220  [0xec] = 0xba,
221  [0xed] = 0xbb,
222  [0xef] = 0xbc,
223  [0xf3] = 0xbd,
224  [0x9b] = 0xbe,
225  [0x9c] = 0xbf, /* 0xb8-0xbf */
226 
227 };
228 
229 static const RzRune ebcdic_uk_to_uni[256] = {
230  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
231  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
232  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
233  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
234  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
235  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
236  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
237  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
238  0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
239  0x00, 0x00, 0x24, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* 0x48-0x4f */
240  0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
241  0x00, 0x00, 0x21, 0xa3, 0x2a, 0x29, 0x3b, 0xac, /* 0x58-0x5f */
242  0x2d, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
243  0x00, 0x00, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* 0x68-0x6f */
244  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
245  0x00, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* 0x78-0x7f */
246  0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x80-0x87 */
247  0x68, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
248  0x00, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 0x90-0x97 */
249  0x71, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
250  0x00, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* 0xa0-0xa7 */
251  0x79, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
252  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
253  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
254  0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0xc0-0xc7 */
255  0x48, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
256  0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* 0xd0-0xd7 */
257  0x51, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
258  0x5c, 0x00, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* 0xe0-0xe7 */
259  0x59, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
260  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0xf0-0xf7 */
261  0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, /* 0xf8-0xff */
262 };
263 
264 static const ut8 ebcdic_uk_from_uni[256] = {
265  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
266  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
267  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
268  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
269  0x40, 0x5a, 0x7f, 0x7b, 0x4a, 0x6c, 0x50, 0x7d, /* 0x20-0x27 */
270  0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* 0x28-0x2f */
271  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x30-0x37 */
272  0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0x38-0x3f */
273  0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x40-0x47 */
274  0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* 0x48-0x4f */
275  0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 0x50-0x57 */
276  0xe7, 0xe8, 0xe9, 0x00, 0xe0, 0x00, 0x00, 0x6d, /* 0x58-0x5f */
277  0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x60-0x67 */
278  0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 0x68-0x6f */
279  0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 0x70-0x77 */
280  0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0x00, 0xff, /* 0x78-0x7f */
281  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
282  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
283  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
284  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
285  0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x6a, 0x00, /* 0xa0-0xa7 */
286  0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0xa1, /* 0xa8-0xaf */
287  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
288  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
289  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
290  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
291  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
292  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
293  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
294  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
295  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
296  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */
297 };
298 
299 static const RzRune ebcdic_us_to_uni[256] = {
300  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
301  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
302  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
303  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
304  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
305  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
306  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
307  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
308  0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
309  0x00, 0x00, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* 0x48-0x4f */
310  0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
311  0x00, 0x00, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac, /* 0x58-0x5f */
312  0x2d, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
313  0x00, 0x00, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* 0x68-0x6f */
314  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
315  0x00, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* 0x78-0x7f */
316  0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x80-0x87 */
317  0x68, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
318  0x00, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 0x90-0x97 */
319  0x71, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
320  0x00, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* 0xa0-0xa7 */
321  0x79, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
322  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
323  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
324  0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0xc0-0xc7 */
325  0x48, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
326  0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* 0xd0-0xd7 */
327  0x51, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
328  0x5c, 0x00, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* 0xe0-0xe7 */
329  0x59, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
330  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0xf0-0xf7 */
331  0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, /* 0xf8-0xff */
332 };
333 
334 static const ut8 ebcdic_us_from_uni[256] = {
335  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
336  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
337  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
338  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
339  0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 0x20-0x27 */
340  0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* 0x28-0x2f */
341  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x30-0x37 */
342  0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0x38-0x3f */
343  0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x40-0x47 */
344  0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* 0x48-0x4f */
345  0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 0x50-0x57 */
346  0xe7, 0xe8, 0xe9, 0x00, 0xe0, 0x00, 0x00, 0x6d, /* 0x58-0x5f */
347  0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x60-0x67 */
348  0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 0x68-0x6f */
349  0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 0x70-0x77 */
350  0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0xff, /* 0x78-0x7f */
351  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
352  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
353  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
354  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
355  0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x6a, 0x00, /* 0xa0-0xa7 */
356  0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
357  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
358  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
359  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
360  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
361  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
362  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
363  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
364  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
365  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
366  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */
367 };
368 
369 static const RzRune ebcdic_es_to_uni[256] = {
370  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
371  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
372  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
373  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
374  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
375  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
376  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
377  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
378  0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
379  0x00, 0x00, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* 0x48-0x4f */
380  0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
381  0x00, 0x00, 0x21, 0x20a7, 0x2a, 0x29, 0x3b, 0xac, /* 0x58-0x5f */
382  0x2d, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
383  0x00, 0x00, 0xf1, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* 0x68-0x6f */
384  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
385  0x00, 0x60, 0x3a, 0xd1, 0x40, 0x27, 0x3d, 0x22, /* 0x78-0x7f */
386  0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x80-0x87 */
387  0x68, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
388  0x00, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 0x90-0x97 */
389  0x71, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
390  0x00, 0xa8, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* 0xa0-0xa7 */
391  0x79, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
392  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
393  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
394  0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0xc0-0xc7 */
395  0x48, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
396  0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* 0xd0-0xd7 */
397  0x51, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
398  0x5c, 0x00, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* 0xe0-0xe7 */
399  0x59, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
400  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0xf0-0xf7 */
401  0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, /* 0xf8-0xff */
402 };
403 
404 static const ut8 ebcdic_es_page00[256] = {
405  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */
406  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */
407  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */
408  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */
409  0x40, 0x5a, 0x7f, 0x00, 0x00, 0x6c, 0x50, 0x7d, /* 0x20-0x27 */
410  0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* 0x28-0x2f */
411  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x30-0x37 */
412  0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0x38-0x3f */
413  0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x40-0x47 */
414  0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* 0x48-0x4f */
415  0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 0x50-0x57 */
416  0xe7, 0xe8, 0xe9, 0x00, 0xe0, 0x00, 0x00, 0x6d, /* 0x58-0x5f */
417  0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x60-0x67 */
418  0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 0x68-0x6f */
419  0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 0x70-0x77 */
420  0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0x00, 0xff, /* 0x78-0x7f */
421  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
422  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
423  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
424  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
425  0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
426  0xa1, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
427  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
428  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
429  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
430  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
431  0x00, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
432  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
433  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
434  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
435  0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
436  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */
437 };
438 
439 static const ut8 ebcdic_es_page20[256] = {
440  [0xa7] = 0x5b,
441 };
442 
448 
459  *dst = ibm037_to_uni[src];
460  return 1;
461 }
462 
471  if (src <= 0xff) {
472  *dst = ibm037_from_uni[src];
473  return 1;
474  }
475  return 0;
476 }
477 
486  ut8 c = ibm037_to_uni[src];
487  if (c < 0x80) {
488  *dst = c;
489  return 1;
490  }
491  return 0;
492 }
493 
502  *dst = ibm037_from_uni[src];
503  return 1;
504 }
505 
507 
514 
518  *dst = ibm290_to_uni[src];
519  return 1;
520 }
521 
525  if (src <= 0xff) {
526  *dst = ibm290_page00[src];
527  return 1;
528  } else if (src >= 0x3000 && src <= 0x30ff) {
529  *dst = ibm290_page30[src & 0xff];
530  return 1;
531  }
532  return 0;
533 }
534 
538  ut8 c = ibm290_to_uni[src];
539  if (c < 0x80) {
540  *dst = c;
541  return 1;
542  }
543  return 0;
544 }
545 
549  *dst = ibm290_page00[src];
550  return 1;
551 }
552 
554 
561 
566  return 1;
567 }
568 
572  if (src <= 0xff) {
574  return 1;
575  }
576  return 0;
577 }
578 
583  if (c < 0x80) {
584  *dst = c;
585  return 1;
586  }
587  return 0;
588 }
589 
594  return 1;
595 }
596 
598 
605 
610  return 1;
611 }
612 
616  if (src <= 0xff) {
618  return 1;
619  }
620  return 0;
621 }
622 
627  if (c < 0x80) {
628  *dst = c;
629  return 1;
630  }
631  return 0;
632 }
633 
638  return 1;
639 }
640 
642 
648 
653  return 1;
654 }
655 
659  if (src <= 0xff) {
661  return 1;
662  } else if (src >= 0x2000 && src <= 0x20ff) {
663  *dst = ebcdic_es_page20[src & 0xff];
664  return 1;
665  }
666  return 0;
667 }
668 
673  if (c < 0x80) {
674  *dst = c;
675  return 1;
676  }
677  return 0;
678 }
679 
684  return 1;
685 }
686 
lzma_index * src
Definition: index.h:567
#define RZ_API
RZ_API int rz_str_ebcdic_uk_from_unicode(RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
Convert an unicode RzRune into an ebcdic_uk char.
Definition: ebcdic.c:570
static const ut8 ebcdic_uk_from_uni[256]
Definition: ebcdic.c:264
RZ_API int rz_str_ebcdic_es_from_ascii(RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
Convert an ascii char into an ebcdic char.
Definition: ebcdic.c:681
RZ_API int rz_str_ibm037_to_unicode(const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
Convert an ibm037 char into an unicode RzRune.
Definition: ebcdic.c:457
RZ_API int rz_str_ebcdic_us_from_ascii(RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
Convert an ascii char into an ebcdic_us char.
Definition: ebcdic.c:635
RZ_API int rz_str_ebcdic_uk_to_ascii(const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
Convert an ebcdic_uk char into an ascii char.
Definition: ebcdic.c:580
RZ_API int rz_str_ibm037_from_ascii(RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
Convert an ascii char into an ibm037 char.
Definition: ebcdic.c:500
RZ_API int rz_str_ebcdic_es_from_unicode(RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
Convert an unicode RzRune into an ebcdic_es char.
Definition: ebcdic.c:657
RZ_API int rz_str_ibm290_to_unicode(const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
Convert an ibm290 char into an unicode RzRune.
Definition: ebcdic.c:516
static const RzRune ibm037_to_uni[256]
Definition: ebcdic.c:22
static const ut8 ibm290_page00[256]
Definition: ebcdic.c:127
RZ_API int rz_str_ebcdic_us_to_ascii(const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
Convert an ebcdic_us char into an ascii char.
Definition: ebcdic.c:624
static const ut8 ibm037_from_uni[256]
Definition: ebcdic.c:57
static const ut8 ebcdic_es_page20[256]
Definition: ebcdic.c:439
RZ_API int rz_str_ebcdic_es_to_unicode(const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
Convert an ebcdic_es char into an unicode RzRune.
Definition: ebcdic.c:650
static const RzRune ebcdic_us_to_uni[256]
Definition: ebcdic.c:299
RZ_API int rz_str_ebcdic_us_to_unicode(const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
Convert an ebcdic_us char into an unicode RzRune.
Definition: ebcdic.c:607
RZ_API int rz_str_ibm290_from_ascii(RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
Convert an ascii char into an ibm290 char.
Definition: ebcdic.c:547
RZ_API int rz_str_ebcdic_uk_from_ascii(RZ_NONNULL RZ_OUT ut8 *dst, const ut8 src)
Convert an ascii char into an ebcdic_uk char.
Definition: ebcdic.c:591
RZ_API int rz_str_ebcdic_uk_to_unicode(const ut8 src, RZ_NONNULL RZ_OUT RzRune *dst)
Convert an ebcdic_uk char into an unicode RzRune.
Definition: ebcdic.c:563
static const RzRune ebcdic_es_to_uni[256]
Definition: ebcdic.c:369
RZ_API int rz_str_ibm037_from_unicode(RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
Convert an unicode RzRune into an ibm037 char.
Definition: ebcdic.c:469
RZ_API int rz_str_ibm290_to_ascii(const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
Convert an ibm290 char into an ascii char.
Definition: ebcdic.c:536
RZ_API int rz_str_ibm037_to_ascii(const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
Convert an ibm037 char into an ascii char.
Definition: ebcdic.c:484
static const ut8 ebcdic_es_page00[256]
Definition: ebcdic.c:404
RZ_API int rz_str_ebcdic_us_from_unicode(RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
Convert an unicode RzRune into an ebcdic_us char.
Definition: ebcdic.c:614
static const ut8 ebcdic_us_from_uni[256]
Definition: ebcdic.c:334
static const ut8 ibm290_page30[256]
Definition: ebcdic.c:162
static const RzRune ibm290_to_uni[256]
Definition: ebcdic.c:92
RZ_API int rz_str_ebcdic_es_to_ascii(const ut8 src, RZ_NONNULL RZ_OUT ut8 *dst)
Convert an ebcdic_es char into an ascii char.
Definition: ebcdic.c:670
RZ_API int rz_str_ibm290_from_unicode(RZ_NONNULL RZ_OUT ut8 *dst, const RzRune src)
Convert an unicode RzRune into an ibm290 char.
Definition: ebcdic.c:523
static const RzRune ebcdic_uk_to_uni[256]
Definition: ebcdic.c:229
uint8_t ut8
Definition: lh5801.h:11
char * dst
Definition: lz4.h:724
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_OUT
Definition: rz_types.h:51
#define RZ_NONNULL
Definition: rz_types.h:64
ut32 RzRune
Definition: rz_utf8.h:13
#define c(i)
Definition: sha256.c:43