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#ifndef _VISCII_TCVN_H_
35#define _VISCII_TCVN_H_
36
37
38
39static const unsigned char viscii2tcvn_1[32] = {
40    /*
41    * 0x00 - Ox1f
42    */
43    0x00,  0x00,  0xba,  0x03,  0x00,  0xbf,  0xc3,  0x07,
44    0x08,  0x09,  0x0a,  0x0b,  0x0c,  0x0d,  0x0e,  0x0f,
45    0x10,  0x00,  0x00,  0x00,  0x14,  0x00,  0x00,  0x00,
46    0x18,  0x15,  0x1a,  0x1b,  0x1c,  0x1d,  0x17,  0x1f,
47};
48
49static const unsigned char viscii2tcvn_2[128] = {
50    /*
51    * 0x80 - Oxff
52    */
53    0x84,  0xc0,  0xaf,  0x85,  0xc4,  0xc1,  0xc2,  0x86,
54    0x89,  0x8b,  0xda,  0xc5,  0xcd,  0xd9,  0x8c,  0xff,
55    0xdb,  0xe0,  0xf0,  0x97,  0x9c,  0x9b,  0x98,  0x99,
56    0x91,  0x93,  0x96,  0x8e,  0x9e,  0x9f,  0x02,  0x13,
57    0x94,  0xbe,  0xbb,  0xc6,  0xca,  0xc7,  0xc8,  0xcb,
58    0xcf,  0xd1,  0xd5,  0xd2,  0xd3,  0xd4,  0xd6,  0xe8,
59    0xe5,  0xe6,  0xe7,  0x9a,  0xa5,  0xe9,  0xea,  0xeb,
60    0xde,  0x12,  0x11,  0x04,  0x05,  0xac,  0xed,  0xa6,
61    0x80,  0x83,  0xa2,  0x82,  0x81,  0xa1,  0xbc,  0xbd,
62    0x87,  0x8a,  0xa3,  0x88,  0x8d,  0x90,  0x8f,  0xfa,
63    0xa7,  0xf8,  0x92,  0x95,  0xa4,  0xb9,  0xfb,  0xf5,
64    0xf6,  0x9d,  0x01,  0xfc,  0xfe,  0x16,  0xec,  0xad,
65    0xb5,  0xb8,  0xa9,  0xb7,  0xb6,  0xa8,  0xf7,  0xc9,
66    0xcc,  0xd0,  0xaa,  0xce,  0xd7,  0xdd,  0xdc,  0xd8,
67    0xae,  0xf9,  0xdf,  0xe3,  0xab,  0xe2,  0xe1,  0xe4,
68    0xf4,  0xef,  0xf3,  0xf2,  0xf1,  0xfd,  0xee,  0x06,
69};
70
71#ifdef  __NEED_VISCII_2_TCVN__
72static int viscii_2_tcvn(const unsigned char *in, unsigned char *out )
73{
74    unsigned char c = *in;
75    if (c < 0x20)
76        *out = (unsigned long) viscii2tcvn_1[c];
77    else if (c < 0x80)
78        *out = (unsigned long) c;
79    else
80        *out = (unsigned long) viscii2tcvn_2[c-0x80];
81    return 1;
82}
83#endif
84
85
86static const unsigned char tcvn2viscii_1[32] = {
87    /*
88    * 0x00 - Ox1f
89    */
90    0x00,  0xda,  0x9e,  0x03,  0xbb,  0xbc,  0xff,  0x07,
91    0x08,  0x09,  0x0a,  0x0b,  0x0c,  0x0d,  0x0e,  0x0f,
92    0x10,  0xba,  0xb9,  0x9f,  0x14,  0x19,  0xdd,  0x1e,
93    0x18,  0x00,  0x1a,  0x1b,  0x1c,  0x1d,  0x00,  0x1f,
94};
95
96static const unsigned char tcvn2viscii_2[128] = {
97    /*
98    * 0x80 - Oxff
99    */
100    0xc0,  0xc4,  0xc3,  0xc1,  0x80,  0x83,  0x87,  0xc8,
101    0xcb,  0x88,  0xc9,  0x89,  0x8e,  0xcc,  0x9b,  0xce,
102    0xcd,  0x98,  0xd2,  0x99,  0xa0,  0xd3,  0x9a,  0x93,
103    0x96,  0x97,  0xb3,  0x95,  0x94,  0xd9,  0x9c,  0x9d,
104    0x00,  0xc5,  0xc2,  0xca,  0xd4,  0xb4,  0xbf,  0xd0,
105    0xe5,  0xe2,  0xea,  0xf4,  0xbd,  0xdf,  0xf0,  0x82,
106    0x00,  0x00,  0x00,  0x00,  0x00,  0xe0,  0xe4,  0xe3,
107    0xe1,  0xd5,  0x02,  0xa2,  0xc6,  0xc7,  0xa1,  0x05,
108    0x81,  0x85,  0x86,  0x06,  0x84,  0x8b,  0xa3,  0xa5,
109    0xa6,  0xe7,  0xa4,  0xa7,  0xe8,  0x8c,  0xeb,  0xa8,
110    0xe9,  0xa9,  0xab,  0xac,  0xad,  0xaa,  0xae,  0xec,
111    0xef,  0x8d,  0x8a,  0x90,  0xee,  0xed,  0xb8,  0xf2,
112    0x91,  0xf6,  0xf5,  0xf3,  0xf7,  0xb0,  0xb1,  0xb2,
113    0xaf,  0xb5,  0xb6,  0xb7,  0xde,  0xbe,  0xfe,  0xf9,
114    0x92,  0xfc,  0xfb,  0xfa,  0xf8,  0xd7,  0xd8,  0xe6,
115    0xd1,  0xf1,  0xcf,  0xd6,  0xdb,  0xfd,  0xdc,  0x8f,
116
117};
118
119#ifdef __NEED_TCVN_2_VISCII__
120static int tcvn_2_viscii (unsigned char in,  unsigned char *out)
121{
122    if (in < 0x20)
123        *out = (unsigned long) tcvn2viscii_1[in];
124    else if (in < 0x80)
125        *out = (unsigned long) in;
126    else
127        *out = (unsigned long) tcvn2viscii_2[in-0x80];
128
129    return 1;
130}
131#endif
132
133#endif
134