xref: /illumos-gate/usr/src/lib/iconv_modules/inc/vi_combine.h (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * COPYRIGHT AND PERMISSION NOTICE
23  *
24  * Copyright (c) 1991-2005 Unicode, Inc. All rights reserved. Distributed
25  *  under the Terms of Use in http://www.unicode.org/copyright.html.
26  *
27  * This file has been modified by Sun Microsystems, Inc.
28  *
29 */
30 /*
31  * Copyright(c) 2008 Sun Microsystems, Inc.
32  * All rights reserved.
33  */
34 
35 #ifndef _VI_COMBINE_H_
36 #define _VI_COMBINE_H_
37 
38 #define VOWEL_NUM 24
39 
40 /*
41  * Unicode of combining characters:
42  * 0x0300, 0x0301, 0x0303, 0x0309, 0x0323.
43  * */
44 typedef struct _combine_map {
45    unsigned short   base;
46    unsigned short   composed[5];
47 } Combine_map;
48 
49 #define ISCOMB_UNI(uni) ((uni)>=0x0300 && (uni)<=0x0323)
50 
51 /* Composition tables for each of the relevant combining characters. */
52 Combine_map vi_comb_data[VOWEL_NUM] = {
53     { 0x0041, {0x00C0, 0x00C1, 0x00C3, 0x1EA2, 0x1EA0}},
54     { 0x0045, {0x00C8, 0x00C9, 0x1EBC, 0x1EBA, 0x1EB8}},
55     { 0x0049, {0x00CC, 0x00CD, 0x0128, 0x1EC8, 0x1ECA}},
56     { 0x004F, {0x00D2, 0x00D3, 0x00D5, 0x1ECE, 0x1ECC}},
57     { 0x0055, {0x00D9, 0x00DA, 0x0168, 0x1EE6, 0x1EE4}},
58     { 0x0059, {0x1EF2, 0x00DD, 0x1EF8, 0x1EF6, 0x1EF4}},
59     { 0x0061, {0x00E0, 0x00E1, 0x00E3, 0x1EA3, 0x1EA1}},
60     { 0x0065, {0x00E8, 0x00E9, 0x1EBD, 0x1EBB, 0x1EB9}},
61     { 0x0069, {0x00EC, 0x00ED, 0x0129, 0x1EC9, 0x1ECB}},
62     { 0x006F, {0x00F2, 0x00F3, 0x00F5, 0x1ECF, 0x1ECD}},
63     { 0x0075, {0x00F9, 0x00FA, 0x0169, 0x1EE7, 0x1EE5}},
64     { 0x0079, {0x1EF3, 0x00FD, 0x1EF9, 0x1EF7, 0x1EF5}},
65     { 0x00C2, {0x1EA6, 0x1EA4, 0x1EAA, 0x1EA8, 0x1EAC}},
66     { 0x00CA, {0x1EC0, 0x1EBE, 0x1EC4, 0x1EC2, 0x1EC6}},
67     { 0x00D4, {0x1ED2, 0x1ED0, 0x1ED6, 0x1ED4, 0x1ED8}},
68     { 0x00E2, {0x1EA7, 0x1EA5, 0x1EAB, 0x1EA9, 0x1EAD}},
69     { 0x00EA, {0x1EC1, 0x1EBF, 0x1EC5, 0x1EC3, 0x1EC7}},
70     { 0x00F4, {0x1ED3, 0x1ED1, 0x1ED7, 0x1ED5, 0x1ED9}},
71     { 0x0102, {0x1EB0, 0x1EAE, 0x1EB4, 0x1EB2, 0x1EB6}},
72     { 0x0103, {0x1EB1, 0x1EAF, 0x1EB5, 0x1EB3, 0x1EB7}},
73     { 0x01A0, {0x1EDC, 0x1EDA, 0x1EE0, 0x1EDE, 0x1EE2}},
74     { 0x01A1, {0x1EDD, 0x1EDB, 0x1EE1, 0x1EDF, 0x1EE3}},
75     { 0x01AF, {0x1EEA, 0x1EE8, 0x1EEE, 0x1EEC, 0x1EF0}},
76     { 0x01B0, {0x1EEB, 0x1EE9, 0x1EEF, 0x1EED, 0x1EF1}},
77 };
78 
79 /* MASK_NUM = (0x01B0 - 0x0041) / 32(bit of unsigned int) + 1 */
80 #define MASK_NUM  12
81 
82 /* Possible Compbine base make.
83  * The possible bases in vi_comb_data:
84  *  0x0041, 0x0045, 0x0049, 0x004F, 0x0055, 0x0059, 0x0061, 0x0065,
85  *  0x0069, 0x006F, 0x0075, 0x0079, 0x00C2, 0x00CA, 0x00D4, 0x00E2,
86  *  0x00EA, 0x00F4, 0x0102, 0x0103, 0x01A0, 0x01A1, 0x01AF, 0x01B0.
87  * */
88 static const unsigned long tcvn_comp_bases_mask[MASK_NUM] = {
89     0x02208222, 0x02208222, 0x00000000, 0x00000000,
90     0x00100404, 0x00100404, 0x0000000c, 0x00000000,
91     0x00000000, 0x00000000, 0x00000000, 0x00018003
92 };
93 
94 
95 /*
96  * TCVN code of combining characters:
97  * 0xb0...0xb4.
98  * */
99 typedef struct _combine_map_tcvn {
100    unsigned char   base;
101    unsigned char   composed[5];
102 } Combine_map_tcvn;
103 
104 #define ISCOMB_TCVN(ch) ((ch)>=0xb0 && (ch)<=0xb4)
105 
106 /* Composition tables for each of the relevant combining characters. */
107 Combine_map_tcvn tcvn_comb_data[VOWEL_NUM] = {
108     {0x41, { 0x80, 0x81, 0x82, 0x83, 0x84 }},
109     {0x45, { 0x87, 0x88, 0x89, 0x8a, 0x8b }},
110     {0x49, { 0x8d, 0x8e, 0x8f, 0x90, 0x91 }},
111     {0x4f, { 0x92, 0x93, 0x94, 0x95, 0x96 }},
112     {0x55, { 0x9d, 0x9e, 0x9f, 0x01, 0x02 }},
113     {0x59, { 0x13, 0x14, 0x15, 0x16, 0x17 }},
114     {0x61, { 0xb5, 0xb6, 0xb7, 0xb8, 0xb9 }},
115     {0x65, { 0xcc, 0xce, 0xcf, 0xd0, 0xd1 }},
116     {0x69, { 0xd7, 0xd8, 0xdc, 0xdd, 0xde }},
117     {0x6f, { 0xdf, 0xe1, 0xe2, 0xe3, 0xe4 }},
118     {0x75, { 0xef, 0xf1, 0xf2, 0xf3, 0xf4 }},
119     {0x79, { 0xfa, 0xfb, 0xfc, 0xfd, 0xfe }},
120     {0xa1, { 0xaf, 0xba, 0xbf, 0xc0, 0x85 }},
121     {0xa2, { 0xc1, 0xc2, 0xc3, 0xc4, 0x86 }},
122     {0xa3, { 0xc5, 0xcd, 0xd9, 0xda, 0x8c }},
123     {0xa4, { 0xdb, 0xe0, 0xf0, 0xff, 0x97 }},
124     {0xa5, { 0x98, 0x99, 0x9a, 0x9b, 0x9c }},
125     {0xa6, { 0x04, 0x05, 0x06, 0x11, 0x12 }},
126     {0xa8, { 0xbb, 0xbc, 0xbd, 0xbe, 0xc6 }},
127     {0xa9, { 0xc7, 0xc8, 0xc9, 0xca, 0xcb }},
128     {0xaa, { 0xd2, 0xd3, 0xd4, 0xd5, 0xd6 }},
129     {0xab, { 0xe5, 0xe6, 0xe7, 0xe8, 0xe9 }},
130     {0xac, { 0xea, 0xeb, 0xec, 0xed, 0xee }},
131     {0xad, { 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 }},
132 };
133 
134 /* MASK_NUM = (0xad - 0x40) / 32 (bit of unsigned int) + 1 */
135 #define MASK_NUM_TCVN  4
136 static const unsigned int tcvn_comp_bases_mask0[MASK_NUM_TCVN] = {
137     0x02208222, 0x02208222,
138     0x00000000, 0x00003f7e,
139 };
140 
141 #endif
142