1*91e1e26aSAlexander Pyhalov /*
2*91e1e26aSAlexander Pyhalov * CDDL HEADER START
3*91e1e26aSAlexander Pyhalov *
4*91e1e26aSAlexander Pyhalov * The contents of this file are subject to the terms of the
5*91e1e26aSAlexander Pyhalov * Common Development and Distribution License (the "License").
6*91e1e26aSAlexander Pyhalov * You may not use this file except in compliance with the License.
7*91e1e26aSAlexander Pyhalov *
8*91e1e26aSAlexander Pyhalov * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
9*91e1e26aSAlexander Pyhalov * or http://www.opensolaris.org/os/licensing.
10*91e1e26aSAlexander Pyhalov * See the License for the specific language governing permissions
11*91e1e26aSAlexander Pyhalov * and limitations under the License.
12*91e1e26aSAlexander Pyhalov *
13*91e1e26aSAlexander Pyhalov * When distributing Covered Code, include this CDDL HEADER in each
14*91e1e26aSAlexander Pyhalov * file and include the License file at src/OPENSOLARIS.LICENSE.
15*91e1e26aSAlexander Pyhalov * If applicable, add the following below this CDDL HEADER, with the
16*91e1e26aSAlexander Pyhalov * fields enclosed by brackets "[]" replaced with your own identifying
17*91e1e26aSAlexander Pyhalov * information: Portions Copyright [yyyy] [name of copyright owner]
18*91e1e26aSAlexander Pyhalov *
19*91e1e26aSAlexander Pyhalov * CDDL HEADER END
20*91e1e26aSAlexander Pyhalov */
21*91e1e26aSAlexander Pyhalov /*
22*91e1e26aSAlexander Pyhalov * COPYRIGHT AND PERMISSION NOTICE
23*91e1e26aSAlexander Pyhalov *
24*91e1e26aSAlexander Pyhalov * Copyright (c) 1991-2005 Unicode, Inc. All rights reserved. Distributed
25*91e1e26aSAlexander Pyhalov * under the Terms of Use in http://www.unicode.org/copyright.html.
26*91e1e26aSAlexander Pyhalov *
27*91e1e26aSAlexander Pyhalov * This file has been modified by Sun Microsystems, Inc.
28*91e1e26aSAlexander Pyhalov *
29*91e1e26aSAlexander Pyhalov */
30*91e1e26aSAlexander Pyhalov /*
31*91e1e26aSAlexander Pyhalov * Copyright(c) 2008 Sun Microsystems, Inc.
32*91e1e26aSAlexander Pyhalov * All rights reserved.
33*91e1e26aSAlexander Pyhalov */
34*91e1e26aSAlexander Pyhalov #ifndef _VISCII_TCVN_H_
35*91e1e26aSAlexander Pyhalov #define _VISCII_TCVN_H_
36*91e1e26aSAlexander Pyhalov
37*91e1e26aSAlexander Pyhalov
38*91e1e26aSAlexander Pyhalov
39*91e1e26aSAlexander Pyhalov static const unsigned char viscii2tcvn_1[32] = {
40*91e1e26aSAlexander Pyhalov /*
41*91e1e26aSAlexander Pyhalov * 0x00 - Ox1f
42*91e1e26aSAlexander Pyhalov */
43*91e1e26aSAlexander Pyhalov 0x00, 0x00, 0xba, 0x03, 0x00, 0xbf, 0xc3, 0x07,
44*91e1e26aSAlexander Pyhalov 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
45*91e1e26aSAlexander Pyhalov 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
46*91e1e26aSAlexander Pyhalov 0x18, 0x15, 0x1a, 0x1b, 0x1c, 0x1d, 0x17, 0x1f,
47*91e1e26aSAlexander Pyhalov };
48*91e1e26aSAlexander Pyhalov
49*91e1e26aSAlexander Pyhalov static const unsigned char viscii2tcvn_2[128] = {
50*91e1e26aSAlexander Pyhalov /*
51*91e1e26aSAlexander Pyhalov * 0x80 - Oxff
52*91e1e26aSAlexander Pyhalov */
53*91e1e26aSAlexander Pyhalov 0x84, 0xc0, 0xaf, 0x85, 0xc4, 0xc1, 0xc2, 0x86,
54*91e1e26aSAlexander Pyhalov 0x89, 0x8b, 0xda, 0xc5, 0xcd, 0xd9, 0x8c, 0xff,
55*91e1e26aSAlexander Pyhalov 0xdb, 0xe0, 0xf0, 0x97, 0x9c, 0x9b, 0x98, 0x99,
56*91e1e26aSAlexander Pyhalov 0x91, 0x93, 0x96, 0x8e, 0x9e, 0x9f, 0x02, 0x13,
57*91e1e26aSAlexander Pyhalov 0x94, 0xbe, 0xbb, 0xc6, 0xca, 0xc7, 0xc8, 0xcb,
58*91e1e26aSAlexander Pyhalov 0xcf, 0xd1, 0xd5, 0xd2, 0xd3, 0xd4, 0xd6, 0xe8,
59*91e1e26aSAlexander Pyhalov 0xe5, 0xe6, 0xe7, 0x9a, 0xa5, 0xe9, 0xea, 0xeb,
60*91e1e26aSAlexander Pyhalov 0xde, 0x12, 0x11, 0x04, 0x05, 0xac, 0xed, 0xa6,
61*91e1e26aSAlexander Pyhalov 0x80, 0x83, 0xa2, 0x82, 0x81, 0xa1, 0xbc, 0xbd,
62*91e1e26aSAlexander Pyhalov 0x87, 0x8a, 0xa3, 0x88, 0x8d, 0x90, 0x8f, 0xfa,
63*91e1e26aSAlexander Pyhalov 0xa7, 0xf8, 0x92, 0x95, 0xa4, 0xb9, 0xfb, 0xf5,
64*91e1e26aSAlexander Pyhalov 0xf6, 0x9d, 0x01, 0xfc, 0xfe, 0x16, 0xec, 0xad,
65*91e1e26aSAlexander Pyhalov 0xb5, 0xb8, 0xa9, 0xb7, 0xb6, 0xa8, 0xf7, 0xc9,
66*91e1e26aSAlexander Pyhalov 0xcc, 0xd0, 0xaa, 0xce, 0xd7, 0xdd, 0xdc, 0xd8,
67*91e1e26aSAlexander Pyhalov 0xae, 0xf9, 0xdf, 0xe3, 0xab, 0xe2, 0xe1, 0xe4,
68*91e1e26aSAlexander Pyhalov 0xf4, 0xef, 0xf3, 0xf2, 0xf1, 0xfd, 0xee, 0x06,
69*91e1e26aSAlexander Pyhalov };
70*91e1e26aSAlexander Pyhalov
71*91e1e26aSAlexander Pyhalov #ifdef __NEED_VISCII_2_TCVN__
viscii_2_tcvn(const unsigned char * in,unsigned char * out)72*91e1e26aSAlexander Pyhalov static int viscii_2_tcvn(const unsigned char *in, unsigned char *out )
73*91e1e26aSAlexander Pyhalov {
74*91e1e26aSAlexander Pyhalov unsigned char c = *in;
75*91e1e26aSAlexander Pyhalov if (c < 0x20)
76*91e1e26aSAlexander Pyhalov *out = (unsigned long) viscii2tcvn_1[c];
77*91e1e26aSAlexander Pyhalov else if (c < 0x80)
78*91e1e26aSAlexander Pyhalov *out = (unsigned long) c;
79*91e1e26aSAlexander Pyhalov else
80*91e1e26aSAlexander Pyhalov *out = (unsigned long) viscii2tcvn_2[c-0x80];
81*91e1e26aSAlexander Pyhalov return 1;
82*91e1e26aSAlexander Pyhalov }
83*91e1e26aSAlexander Pyhalov #endif
84*91e1e26aSAlexander Pyhalov
85*91e1e26aSAlexander Pyhalov
86*91e1e26aSAlexander Pyhalov static const unsigned char tcvn2viscii_1[32] = {
87*91e1e26aSAlexander Pyhalov /*
88*91e1e26aSAlexander Pyhalov * 0x00 - Ox1f
89*91e1e26aSAlexander Pyhalov */
90*91e1e26aSAlexander Pyhalov 0x00, 0xda, 0x9e, 0x03, 0xbb, 0xbc, 0xff, 0x07,
91*91e1e26aSAlexander Pyhalov 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
92*91e1e26aSAlexander Pyhalov 0x10, 0xba, 0xb9, 0x9f, 0x14, 0x19, 0xdd, 0x1e,
93*91e1e26aSAlexander Pyhalov 0x18, 0x00, 0x1a, 0x1b, 0x1c, 0x1d, 0x00, 0x1f,
94*91e1e26aSAlexander Pyhalov };
95*91e1e26aSAlexander Pyhalov
96*91e1e26aSAlexander Pyhalov static const unsigned char tcvn2viscii_2[128] = {
97*91e1e26aSAlexander Pyhalov /*
98*91e1e26aSAlexander Pyhalov * 0x80 - Oxff
99*91e1e26aSAlexander Pyhalov */
100*91e1e26aSAlexander Pyhalov 0xc0, 0xc4, 0xc3, 0xc1, 0x80, 0x83, 0x87, 0xc8,
101*91e1e26aSAlexander Pyhalov 0xcb, 0x88, 0xc9, 0x89, 0x8e, 0xcc, 0x9b, 0xce,
102*91e1e26aSAlexander Pyhalov 0xcd, 0x98, 0xd2, 0x99, 0xa0, 0xd3, 0x9a, 0x93,
103*91e1e26aSAlexander Pyhalov 0x96, 0x97, 0xb3, 0x95, 0x94, 0xd9, 0x9c, 0x9d,
104*91e1e26aSAlexander Pyhalov 0x00, 0xc5, 0xc2, 0xca, 0xd4, 0xb4, 0xbf, 0xd0,
105*91e1e26aSAlexander Pyhalov 0xe5, 0xe2, 0xea, 0xf4, 0xbd, 0xdf, 0xf0, 0x82,
106*91e1e26aSAlexander Pyhalov 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xe4, 0xe3,
107*91e1e26aSAlexander Pyhalov 0xe1, 0xd5, 0x02, 0xa2, 0xc6, 0xc7, 0xa1, 0x05,
108*91e1e26aSAlexander Pyhalov 0x81, 0x85, 0x86, 0x06, 0x84, 0x8b, 0xa3, 0xa5,
109*91e1e26aSAlexander Pyhalov 0xa6, 0xe7, 0xa4, 0xa7, 0xe8, 0x8c, 0xeb, 0xa8,
110*91e1e26aSAlexander Pyhalov 0xe9, 0xa9, 0xab, 0xac, 0xad, 0xaa, 0xae, 0xec,
111*91e1e26aSAlexander Pyhalov 0xef, 0x8d, 0x8a, 0x90, 0xee, 0xed, 0xb8, 0xf2,
112*91e1e26aSAlexander Pyhalov 0x91, 0xf6, 0xf5, 0xf3, 0xf7, 0xb0, 0xb1, 0xb2,
113*91e1e26aSAlexander Pyhalov 0xaf, 0xb5, 0xb6, 0xb7, 0xde, 0xbe, 0xfe, 0xf9,
114*91e1e26aSAlexander Pyhalov 0x92, 0xfc, 0xfb, 0xfa, 0xf8, 0xd7, 0xd8, 0xe6,
115*91e1e26aSAlexander Pyhalov 0xd1, 0xf1, 0xcf, 0xd6, 0xdb, 0xfd, 0xdc, 0x8f,
116*91e1e26aSAlexander Pyhalov
117*91e1e26aSAlexander Pyhalov };
118*91e1e26aSAlexander Pyhalov
119*91e1e26aSAlexander Pyhalov #ifdef __NEED_TCVN_2_VISCII__
tcvn_2_viscii(unsigned char in,unsigned char * out)120*91e1e26aSAlexander Pyhalov static int tcvn_2_viscii (unsigned char in, unsigned char *out)
121*91e1e26aSAlexander Pyhalov {
122*91e1e26aSAlexander Pyhalov if (in < 0x20)
123*91e1e26aSAlexander Pyhalov *out = (unsigned long) tcvn2viscii_1[in];
124*91e1e26aSAlexander Pyhalov else if (in < 0x80)
125*91e1e26aSAlexander Pyhalov *out = (unsigned long) in;
126*91e1e26aSAlexander Pyhalov else
127*91e1e26aSAlexander Pyhalov *out = (unsigned long) tcvn2viscii_2[in-0x80];
128*91e1e26aSAlexander Pyhalov
129*91e1e26aSAlexander Pyhalov return 1;
130*91e1e26aSAlexander Pyhalov }
131*91e1e26aSAlexander Pyhalov #endif
132*91e1e26aSAlexander Pyhalov
133*91e1e26aSAlexander Pyhalov #endif
134