Commit | Line | Data |
1d72bdf6 |
1 | /* utfebcdic.h |
2 | * |
663f364b |
3 | * Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, by Larry Wall, Nick |
699a97de |
4 | * Ing-Simmons, and others |
1d72bdf6 |
5 | * |
6 | * You may distribute under the terms of either the GNU General Public |
7 | * License or the Artistic License, as specified in the README file. |
8 | * |
9 | * Macros to implement UTF-EBCDIC as perl's internal encoding |
10 | * Taken from version 7.1 of Unicode Techical Report #16: |
11 | * http://www.unicode.org/unicode/reports/tr16 |
fe749c9a |
12 | * |
13 | * To summarize, the way it works is: |
14 | * To convert an EBCDIC character to UTF-EBCDIC: |
15 | * 1) convert to Unicode. The table in this file that does this is for |
16 | * EBCDIC bytes is PL_e2a (with inverse PLa2e). The 'a' stands for |
17 | * ASCIIish, meaning latin1. |
18 | * 2) convert that to a utf8-like string called I8 with variant characters |
19 | * occupying multiple bytes. This step is similar to the utf8-creating |
20 | * step from Unicode, but the details are different. There is a chart |
21 | * about the bit patterns in a comment later in this file. But |
22 | * essentially here are the differences: |
23 | * UTF8 I8 |
24 | * invariant byte starts with 0 starts with 0 or 100 |
25 | * continuation byte starts with 10 starts with 101 |
26 | * start byte same in both: if the code point requires N bytes, |
27 | * then the leading N bits are 1, followed by a 0. (No |
28 | * trailing 0 for the very largest possible allocation |
29 | * in I8, far beyond the current Unicode standard's |
30 | * max, as shown in the comment later in this file.) |
31 | * 3) Use the table published in tr16 to convert each byte from step 2 into |
32 | * final UTF-EBCDIC. The table in this file is PL_utf2e, and its invverse |
33 | * is PL_e2utf. They are constructed so that all EBCDIC invariants remain |
34 | * invariant, but no others do. For example, the ordinal value of 'A' is |
35 | * 193 in EBCDIC, and also is 193 in UTF-EBCDIC. Step 1) converts it to |
36 | * 65, Step 2 leaves it at 65, and Step 3 converts it back to 193. As an |
37 | * example of how a variant character works, take LATIN SMALL LETTER Y |
38 | * WITH DIAERESIS, which is typicially 0xDF in EBCDIC. Step 1 converts it |
39 | * to the Unicode value, 0xFF. Step 2 converts that to two bytes = |
40 | * 11000111 10111111 = C7 BF, and Step 3 converts those to 0x47 0xE7 |
41 | * |
42 | * If you're starting from Unicode, skip step 1. For UTF-EBCDIC to straight |
43 | * EBCDIC, reverse the steps. |
44 | * |
45 | * The EBCDIC invariants have been chosen to be those characters whose Unicode |
46 | * equivalents have ordinal numbers less than 160, that is the same characters |
47 | * that are expressible in ASCII, plus the C1 controls. So there are 160 |
48 | * invariants instead of the 128 in UTF-8. (My guess is that this is because |
49 | * the C1 control NEL (and maybe others) is important in IBM.) |
50 | * |
51 | * The purpose of Step 3 is to make the encoding be invariant for the chosen |
52 | * characters. This messes up the convenient patterns found in step 2, so |
53 | * generally, one has to undo step 3 into a temporary to use them. However, |
54 | * a "shadow", or parallel table, PL_utf8skip, has been constructed so that for |
55 | * each byte, it says how long the sequence is if that byte were to begin it |
56 | * |
57 | * There are actually 3 slightly different UTF-EBCDIC encodings in this file, |
58 | * one for each of the code pages recognized by Perl. That means that there |
59 | * are actually three different sets of tables, one for each code page. (If |
60 | * Perl is compiled on platforms using other EBCDIC code pages, it may not |
61 | * compile, or silently mistake it for one of the three.) |
62 | * |
63 | * EBCDIC characters above 0xFF are the same as Unicode in Perl's |
64 | * implementation of all 3 encodings, so for those Step 1 is trivial. |
65 | * |
66 | * (Note that the entries for invariant characters are necessarily the same in |
67 | * PL_e2a and PLe2f, and the same for their inverses.) |
68 | * |
69 | * UTF-EBCDIC strings are the same length or longer than UTF-8 representations |
70 | * of the same string. The maximum code point representable as 2 bytes in |
71 | * UTF-EBCDIC is 0x3FFF, instead of 0x7FFF in UTF-8. |
1d72bdf6 |
72 | */ |
73 | |
74 | START_EXTERN_C |
75 | |
76 | #ifdef DOINIT |
77 | /* Indexed by encoded byte this table gives the length of the sequence. |
78 | Adapted from the shadow flags table in tr16. |
c4d5f83a |
79 | The entries marked 9 in tr6 are continuation bytes and are marked |
80 | as length 1 here so that we can recover. |
1d72bdf6 |
81 | */ |
f5e1abaf |
82 | #if '^' == 95 /* if defined(__MVS__) || defined(??) (VM/ESA?) 1047 */ |
1d72bdf6 |
83 | EXTCONST unsigned char PL_utf8skip[] = { |
84 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
85 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
86 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
87 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
c4d5f83a |
88 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
89 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
90 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
91 | 1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1, |
1d72bdf6 |
92 | 2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2, |
93 | 2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2, |
94 | 2,1,1,1,1,1,1,1,1,1,2,2,2,1,2,2, |
95 | 2,2,2,2,2,2,2,3,3,3,3,3,3,1,3,3, |
96 | 1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3, |
97 | 1,1,1,1,1,1,1,1,1,1,3,3,4,4,4,4, |
98 | 1,4,1,1,1,1,1,1,1,1,4,4,4,5,5,5, |
99 | 1,1,1,1,1,1,1,1,1,1,5,6,6,7,7,1 |
100 | }; |
f5e1abaf |
101 | #endif |
102 | |
103 | #if '^' == 106 /* if defined(_OSD_POSIX) POSIX-BC */ |
104 | unsigned char PL_utf8skip[] = { |
105 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
106 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
107 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
108 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
109 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
110 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
111 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
112 | 1,1,1,1,2,2,2,2,2,3,1,1,1,1,1,1, |
113 | 2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2, |
114 | 2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2, |
115 | 2,3,1,1,1,1,1,1,1,1,2,2,2,3,2,2, |
116 | 1,2,2,2,2,2,2,3,3,3,2,1,1,1,3,3, |
117 | 4,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3, |
118 | 1,1,1,1,1,1,1,1,1,1,3,3,4,6,4,4, |
119 | 7,4,1,1,1,1,1,1,1,1,4,4,4,5,5,5, |
120 | 1,1,1,1,1,1,1,1,1,1,5,1,6,1,7,1 |
121 | }; |
122 | #endif |
123 | |
124 | #if '^' == 176 /* if defined(??) (OS/400?) 037 */ |
125 | unsigned char PL_utf8skip[] = { |
126 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
127 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
128 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
129 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
130 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
131 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2, |
132 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
133 | 1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1, |
134 | 2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2, |
135 | 2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2, |
136 | 2,1,1,1,1,1,1,1,1,1,2,2,2,3,2,2, |
137 | 1,2,2,2,2,2,2,3,3,3,1,1,3,3,3,3, |
138 | 1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3, |
139 | 1,1,1,1,1,1,1,1,1,1,3,3,4,4,4,4, |
140 | 1,4,1,1,1,1,1,1,1,1,4,4,4,5,5,5, |
141 | 1,1,1,1,1,1,1,1,1,1,5,6,6,7,7,1 |
142 | }; |
143 | #endif |
1d72bdf6 |
144 | |
fe749c9a |
145 | /* Transform tables from tr16 applied after encoding to render encoding EBCDIC |
146 | * like, meaning that all the invariants are actually invariant, eg, that 'A' |
147 | * remains 'A' */ |
1d72bdf6 |
148 | |
f5e1abaf |
149 | #if '^' == 95 /* if defined(__MVS__) || defined(??) (VM/ESA?) 1047 */ |
1d72bdf6 |
150 | EXTCONST unsigned char PL_utf2e[] = { /* UTF-8-mod to EBCDIC (IBM-1047) */ |
151 | 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
152 | 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, |
153 | 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, |
154 | 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, |
155 | 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, |
156 | 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, |
157 | 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, |
158 | 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, |
159 | 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, |
160 | 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, |
161 | 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, |
162 | 0x57, 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x70, 0x71, 0x72, 0x73, |
163 | 0x74, 0x75, 0x76, 0x77, 0x78, 0x80, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x9A, 0x9B, 0x9C, |
164 | 0x9D, 0x9E, 0x9F, 0xA0, 0xAA, 0xAB, 0xAC, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, |
165 | 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBE, 0xBF, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xDA, 0xDB, |
166 | 0xDC, 0xDD, 0xDE, 0xDF, 0xE1, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, |
167 | }; |
168 | |
f5e1abaf |
169 | EXTCONST unsigned char PL_e2utf[] = { /* EBCDIC (IBM-1047) to UTF-8-mod */ |
1d72bdf6 |
170 | 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
171 | 0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, 0x18, 0x19, 0x92, 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, 0x47, 0x48, 0x49, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, |
183 | 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, |
184 | 0x5C, 0xF4, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, |
185 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x9F, |
186 | }; |
f5e1abaf |
187 | #endif /* 1047 */ |
188 | |
189 | #if '^' == 106 /* if defined(_OSD_POSIX) POSIX-BC */ |
190 | unsigned char PL_utf2e[] = { /* UTF-8-mod to EBCDIC (POSIX-BC) */ |
191 | 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
192 | 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, |
193 | 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, |
194 | 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, |
195 | 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, |
196 | 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xBB, 0xBC, 0xBD, 0x6A, 0x6D, |
197 | 0x4A, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, |
198 | 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xFB, 0x4F, 0xFD, 0xFF, 0x07, |
199 | 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, |
200 | 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0x5F, |
201 | 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xB0, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, |
202 | 0x57, 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0xD0, 0x70, 0x71, 0x72, 0x73, |
203 | 0x74, 0x75, 0x76, 0x77, 0x78, 0x80, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x9A, 0x9B, 0x9C, |
204 | 0x9D, 0x9E, 0x9F, 0xA0, 0xAA, 0xAB, 0xAC, 0xAE, 0xAF, 0xBA, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, |
205 | 0xB7, 0xB8, 0xB9, 0xAD, 0x79, 0xA1, 0xBE, 0xBF, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xDA, 0xDB, |
206 | 0xDC, 0xC0, 0xDE, 0xDF, 0xE1, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xFA, 0xDD, 0xFC, 0xE0, 0xFE, |
207 | }; |
208 | |
209 | unsigned char PL_e2utf[] = { /* EBCDIC (POSIX-BC) to UTF-8-mod */ |
210 | 0x00, 0x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D8, |
221 | 0xA9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xD9, 0x5B, 0x5C, 0x5D, 0xE6, 0xE7, |
222 | 0xF1, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, |
223 | 0xBB, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0xEE, 0xEF, 0xF0, 0xFC, 0xF2, 0xF3, |
224 | 0xFE, 0xF4, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, |
225 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xFB, 0x7B, 0xFD, 0x7D, 0xFF, 0x7E, |
226 | }; |
227 | #endif /* POSIX-BC */ |
228 | |
229 | #if '^' == 176 /* if defined(??) (OS/400?) 037 */ |
230 | unsigned char PL_utf2e[] = { /* UTF-8-mod to EBCDIC (IBM-037) */ |
231 | 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, 0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
232 | 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, |
233 | 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, |
234 | 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, |
235 | 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, |
236 | 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xBA, 0xE0, 0xBB, 0xB0, 0x6D, |
237 | 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, |
238 | 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, |
239 | 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, |
240 | 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, |
241 | 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, |
242 | 0x57, 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x70, 0x71, 0x72, 0x73, |
243 | 0x74, 0x75, 0x76, 0x77, 0x78, 0x80, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x9A, 0x9B, 0x9C, |
244 | 0x9D, 0x9E, 0x9F, 0xA0, 0xAA, 0xAB, 0xAC, 0xAE, 0xAF, 0x5F, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, |
245 | 0xB7, 0xB8, 0xB9, 0xAD, 0xBD, 0xBC, 0xBE, 0xBF, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xDA, 0xDB, |
246 | 0xDC, 0xDD, 0xDE, 0xDF, 0xE1, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, |
247 | }; |
248 | |
249 | unsigned char PL_e2utf[] = { /* EBCDIC (IBM-037) to UTF-8-mod */ |
250 | 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
251 | 0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, |
252 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, |
253 | 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, |
254 | 0x20, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, |
255 | 0x26, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xD9, |
256 | 0x2D, 0x2F, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, |
257 | 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, |
258 | 0xC5, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, |
259 | 0xCC, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, |
260 | 0xD3, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xD4, 0xD5, 0xD6, 0xE3, 0xD7, 0xD8, |
261 | 0x5E, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0x5B, 0x5D, 0xE5, 0xE4, 0xE6, 0xE7, |
262 | 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, |
263 | 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, |
264 | 0x5C, 0xF4, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, |
265 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x9F, |
266 | }; |
267 | #endif /* 037 */ |
1d72bdf6 |
268 | |
269 | /* These tables moved from perl.h and converted to hex. |
270 | They map platfrom code page from/to bottom 256 codes of Unicode (i.e. iso-8859-1). |
271 | */ |
272 | |
273 | #if '^' == 95 /* if defined(__MVS__) || defined(??) (VM/ESA?) 1047 */ |
274 | EXTCONST unsigned char PL_a2e[] = { /* ASCII (iso-8859-1) to EBCDIC (IBM-1047) */ |
275 | 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
276 | 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, |
277 | 0x40, 0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75, 0x76, 0x77, |
288 | 0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, 0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xBA, 0xAE, 0x59, |
289 | 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, |
290 | 0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, 0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF |
291 | }; |
292 | |
431fc773 |
293 | EXTCONST unsigned char PL_e2a[] = { /* EBCDIC (IBM-1047) to ASCII (iso-8859-1) */ |
1d72bdf6 |
294 | 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
295 | 0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, |
296 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1B, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, |
297 | 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, |
298 | 0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, 0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, |
299 | 0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, 0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, |
300 | 0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, 0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, |
301 | 0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, 0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, |
302 | 0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, |
303 | 0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, |
304 | 0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0x5B, 0xDE, 0xAE, |
305 | 0xAC, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, 0xBD, 0xBE, 0xDD, 0xA8, 0xAF, 0x5D, 0xB4, 0xD7, |
306 | 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, |
307 | 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, |
308 | 0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, |
309 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F |
310 | }; |
311 | #endif /* 1047 */ |
312 | |
313 | #if '^' == 106 /* if defined(_OSD_POSIX) POSIX-BC */ |
314 | EXTCONST unsigned char PL_a2e[] = { /* ASCII (ISO8859-1) to EBCDIC (POSIX-BC) */ |
315 | 0x00, 0x01, 0x02, 0x03, 0x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 0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, 0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, |
327 | 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, |
328 | 0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, 0x80, 0xE0, 0xFE, 0xDD, 0xFC, 0xAD, 0xAE, 0x59, |
329 | 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, |
330 | 0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, 0x70, 0xC0, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF |
331 | }; |
332 | |
333 | EXTCONST unsigned char PL_e2a[] = { /* EBCDIC (POSIX-BC) to ASCII (ISO8859-1) */ |
334 | 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
335 | 0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, |
336 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1B, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, |
337 | 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, |
338 | 0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, 0xE7, 0xF1, 0x60, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, |
339 | 0x26, 0xE9, 0xEA, 0xEB, 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
350 | }; |
351 | #endif /* POSIX-BC */ |
f5e1abaf |
352 | |
1d72bdf6 |
353 | #if '^' == 176 /* if defined(??) (OS/400?) 037 */ |
354 | EXTCONST unsigned char PL_a2e[] = { /* ASCII (ISO8859-1) to EBCDIC (IBM-037) */ |
355 | 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, 0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
356 | 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, |
357 | 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, |
358 | 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, |
359 | 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, |
360 | 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xBA, 0xE0, 0xBB, 0xB0, 0x6D, |
361 | 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, |
362 | 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, |
363 | 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, |
364 | 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, |
365 | 0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, 0xBD, 0xB4, 0x9A, 0x8A, 0x5F, 0xCA, 0xAF, 0xBC, |
366 | 0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, 0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, |
367 | 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, |
368 | 0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, 0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xAD, 0xAE, 0x59, |
369 | 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, |
370 | 0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, 0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF |
371 | }; |
372 | |
373 | EXTCONST unsigned char PL_e2a[] = { /* EBCDIC (IBM-037) to ASCII (ISO8859-1) */ |
374 | 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
375 | 0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, |
376 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, |
377 | 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98,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x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, |
389 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F |
390 | }; |
391 | #endif /* 037 */ |
392 | |
393 | #else |
394 | EXTCONST unsigned char PL_utf8skip[]; |
395 | EXTCONST unsigned char PL_e2utf[]; |
396 | EXTCONST unsigned char PL_utf2e[]; |
397 | EXTCONST unsigned char PL_e2a[]; |
398 | EXTCONST unsigned char PL_a2e[]; |
399 | #endif |
400 | |
401 | END_EXTERN_C |
402 | |
66af24e1 |
403 | #define UTF8SKIP(s) PL_utf8skip[*(const U8*)(s)] |
1d72bdf6 |
404 | |
1e54db1a |
405 | /* EBCDIC-happy ways of converting native code to UTF-8 */ |
1d72bdf6 |
406 | |
407 | /* Native to iso-8859-1 */ |
408 | #define NATIVE_TO_ASCII(ch) PL_e2a[(U8)(ch)] |
409 | #define ASCII_TO_NATIVE(ch) PL_a2e[(U8)(ch)] |
410 | /* Transform after encoding */ |
411 | #define NATIVE_TO_UTF(ch) PL_e2utf[(U8)(ch)] |
412 | #define UTF_TO_NATIVE(ch) PL_utf2e[(U8)(ch)] |
413 | /* Transform in wide UV char space */ |
414 | #define NATIVE_TO_UNI(ch) (((ch) > 255) ? (ch) : NATIVE_TO_ASCII(ch)) |
c4d5f83a |
415 | #define UNI_TO_NATIVE(ch) (((ch) > 255) ? (ch) : ASCII_TO_NATIVE(ch)) |
1d72bdf6 |
416 | /* Transform in invariant..byte space */ |
417 | #define NATIVE_TO_NEED(enc,ch) ((enc) ? UTF_TO_NATIVE(NATIVE_TO_ASCII(ch)) : (ch)) |
418 | #define ASCII_TO_NEED(enc,ch) ((enc) ? UTF_TO_NATIVE(ch) : ASCII_TO_NATIVE(ch)) |
419 | |
420 | /* |
421 | * Note: we should try and be careful never to call the isXXX_utf8() functions |
422 | * unless we're pretty sure we've seen the beginning of a UTF-EBCDIC character |
979f2922 |
423 | * Otherwise we risk loading in the heavy-duty swash_init and swash_fetch |
424 | * routines unnecessarily. |
1d72bdf6 |
425 | */ |
426 | |
0064a8a9 |
427 | #define isIDFIRST_lazy_if(p,c) ((IN_BYTES || (!c || UTF8_IS_INVARIANT(*p))) \ |
1d72bdf6 |
428 | ? isIDFIRST(*(p)) \ |
e1ec3a88 |
429 | : isIDFIRST_utf8((const U8*)p)) |
0064a8a9 |
430 | #define isALNUM_lazy_if(p,c) ((IN_BYTES || (!c || UTF8_IS_INVARIANT(*p))) \ |
1d72bdf6 |
431 | ? isALNUM(*(p)) \ |
e1ec3a88 |
432 | : isALNUM_utf8((const U8*)p)) |
1d72bdf6 |
433 | |
434 | /* |
435 | The following table is adapted from tr16, it shows UTF-8-mod encoding of Unicode code points. |
436 | |
437 | Unicode Bit pattern 1st Byte 2nd Byte 3rd Byte 4th Byte 5th Byte 6th Byte 7th byte |
438 | U+0000..U+007F 000000000xxxxxxx 0xxxxxxx |
439 | U+0080..U+009F 00000000100xxxxx 100xxxxx |
440 | U+00A0..U+00FF 00000000yyyxxxxx 11000yyy 101xxxxx |
441 | |
442 | U+00A0..U+03FF 000000yyyyyxxxxx 110yyyyy 101xxxxx |
443 | U+0400..U+3FFF 00zzzzyyyyyxxxxx 1110zzzz 101yyyyy 101xxxxx |
444 | U+4000..U+3FFFF 0wwwzzzzzyyyyyxxxxx 11110www 101zzzzz 101yyyyy 101xxxxx |
445 | U+40000..U+3FFFFF 0vvwwwwwzzzzzyyyyyxxxxx 111110vv 101wwwww 101zzzzz 101yyyyy 101xxxxx |
446 | U+400000..U+3FFFFFF 0uvvvvvwwwwwzzzzzyyyyyxxxxx 1111110u 101vvvvv 101wwwww 101zzzzz 101yyyyy 101xxxxx |
447 | U+4000000..U+7FFFFFFF 0tuuuuuvvvvvwwwwwzzzzzyyyyyxxxxx 1111111t 101uuuuu 101vvvvv 101wwwww 101zzzzz 101yyyyy 101xxxxx |
448 | |
449 | Note: The UTF-8-Mod transformation is valid for UCS-4 values X'0' to |
450 | X'7FFFFFFF' (the full extent of ISO/IEC 10646 coding space). |
451 | |
452 | */ |
453 | |
454 | #define UNISKIP(uv) ( (uv) < 0xA0 ? 1 : \ |
455 | (uv) < 0x400 ? 2 : \ |
456 | (uv) < 0x4000 ? 3 : \ |
457 | (uv) < 0x40000 ? 4 : \ |
458 | (uv) < 0x400000 ? 5 : \ |
459 | (uv) < 0x4000000 ? 6 : 7 ) |
460 | |
c4d5f83a |
461 | |
462 | #define UNI_IS_INVARIANT(c) ((c) < 0xA0) |
1d72bdf6 |
463 | /* UTF-EBCDIC sematic macros - transform back into UTF-8-Mod and then compare */ |
c4d5f83a |
464 | #define NATIVE_IS_INVARIANT(c) UNI_IS_INVARIANT(NATIVE_TO_ASCII(c)) |
465 | #define UTF8_IS_INVARIANT(c) UNI_IS_INVARIANT(NATIVE_TO_UTF(c)) |
1d72bdf6 |
466 | #define UTF8_IS_START(c) (NATIVE_TO_UTF(c) >= 0xA0 && (NATIVE_TO_UTF(c) & 0xE0) != 0xA0) |
2b9d42f0 |
467 | #define UTF8_IS_CONTINUATION(c) ((NATIVE_TO_UTF(c) & 0xE0) == 0xA0) |
1d72bdf6 |
468 | #define UTF8_IS_CONTINUED(c) (NATIVE_TO_UTF(c) >= 0xA0) |
469 | #define UTF8_IS_DOWNGRADEABLE_START(c) (NATIVE_TO_UTF(c) >= 0xA0 && (NATIVE_TO_UTF(c) & 0xF8) == 0xC0) |
470 | |
471 | #define UTF_START_MARK(len) ((len > 7) ? 0xFF : (0xFE << (7-len))) |
472 | #define UTF_START_MASK(len) ((len >= 6) ? 0x01 : (0x1F >> (len-2))) |
473 | #define UTF_CONTINUATION_MARK 0xA0 |
474 | #define UTF_CONTINUATION_MASK ((U8)0x1f) |
475 | #define UTF_ACCUMULATION_SHIFT 5 |
476 | |
75383841 |
477 | #define UTF8_ACCUMULATE(old, new) (((old) << UTF_ACCUMULATION_SHIFT)|(NATIVE_TO_UTF(new) & UTF_CONTINUATION_MASK)) |
1d72bdf6 |
478 | |
479 | /* UTF-EBCDIC encode a downgradeable value */ |
480 | #define UTF8_EIGHT_BIT_HI(c) UTF_TO_NATIVE((((U8)(c))>>UTF_ACCUMULATION_SHIFT)|UTF_START_MARK(2)) |
481 | #define UTF8_EIGHT_BIT_LO(c) UTF_TO_NATIVE(((((U8)(c)))&UTF_CONTINUATION_MASK)|UTF_CONTINUATION_MARK) |
482 | |
e9a8c099 |
483 | /* |
484 | * Local variables: |
485 | * c-indentation-style: bsd |
486 | * c-basic-offset: 4 |
487 | * indent-tabs-mode: t |
488 | * End: |
489 | * |
490 | * ex: set ts=8 sts=4 sw=4 noet: |
491 | */ |