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