4
* All rights reserved. Copyright (C) 1996 by NARITA Tomio.
5
* $Id: unirev.c,v 1.6 2003/11/13 03:08:19 nrt Exp $
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
#define ISO8859_TO_UNI
37
#include <iso88592.rev>
38
#include <iso88593.rev>
39
#include <iso88594.rev>
40
#include <iso88595.rev>
41
#include <iso88596.rev>
42
#include <iso88597.rev>
43
#include <iso88598.rev>
44
#include <iso88599.rev>
45
#include <iso885910.rev>
46
#include <iso885911.rev>
47
#include <iso885913.rev>
48
#include <iso885914.rev>
49
#include <iso885915.rev>
50
#include <iso885916.rev>
62
#include <jis0208.rev>
63
#include <jis0212.rev>
67
#include <ksc5601.rev>
70
private ic_t ISO8859_1toUNI( ic_t ic, byte *cset )
76
private ic_t CNStoUNI( ic_t ic, byte *cset )
80
res = CNStoBIG5( ic, cset );
82
return RevUNI( res, cset );
87
private ic_t ASCIItoUNI( ic_t ic, byte *cset )
93
private ic_t JIS0201ROMANtoUNI( ic_t ic, byte *cset )
98
} else if( ic == 0x7e ){
106
private ic_t JIS0201KANAtoUNI( ic_t ic, byte *cset )
112
typedef ic_t (*uniconv_t)( ic_t ic, byte *cset );
121
private rev_table_t revTable[ PSEUDO ] = {
122
{ NULL, NULL, 0, ASCIItoUNI }, /* ASCII */
123
{ NULL, NULL, 0, JIS0201ROMANtoUNI }, /* X0201ROMAN */
124
{ NULL, NULL, 0, JIS0201KANAtoUNI }, /* X0201KANA */
125
{ NULL, NULL, 0, ISO8859_1toUNI }, /* ISO8859_1 */
126
#ifdef ISO8859_TO_UNI
127
{ revISO8859_2, NULL, 0, NULL }, /* ISO8859_2 */
128
{ revISO8859_3, NULL, 0, NULL }, /* ISO8859_3 */
129
{ revISO8859_4, NULL, 0, NULL }, /* ISO8859_4 */
130
{ revISO8859_5, NULL, 0, NULL }, /* ISO8859_5 */
131
{ revISO8859_6, NULL, 0, NULL }, /* ISO8859_6 */
132
{ revISO8859_7, NULL, 0, NULL }, /* ISO8859_7 */
133
{ revISO8859_8, NULL, 0, NULL }, /* ISO8859_8 */
134
{ revISO8859_9, NULL, 0, NULL }, /* ISO8859_9 */
135
{ revISO8859_10, NULL, 0, NULL }, /* ISO8859_10 */
136
{ revISO8859_11, NULL, 0, NULL }, /* ISO8859_11 */
137
{ revISO8859_13, NULL, 0, NULL }, /* ISO8859_13 */
138
{ revISO8859_14, NULL, 0, NULL }, /* ISO8859_14 */
139
{ revISO8859_15, NULL, 0, NULL }, /* ISO8859_15 */
140
{ revISO8859_16, NULL, 0, NULL }, /* ISO8859_16 */
142
{ NULL, NULL, 0, NULL },
143
{ NULL, NULL, 0, NULL },
144
{ NULL, NULL, 0, NULL },
145
{ NULL, NULL, 0, NULL },
146
{ NULL, NULL, 0, NULL },
147
{ NULL, NULL, 0, NULL },
148
{ NULL, NULL, 0, NULL },
149
{ NULL, NULL, 0, NULL },
150
{ NULL, NULL, 0, NULL },
151
{ NULL, NULL, 0, NULL },
152
{ NULL, NULL, 0, NULL },
153
{ NULL, NULL, 0, NULL },
154
{ NULL, NULL, 0, NULL },
155
{ NULL, NULL, 0, NULL },
158
{ NULL, revJIS0208, 6878, NULL }, /* C6226 */
160
{ NULL, NULL, 0, NULL },
163
{ NULL, revGB2312, 7444, NULL }, /* GB2312 */
165
{ NULL, NULL, 0, NULL },
168
{ NULL, revJIS0208, 6878, NULL }, /* X0208 */
170
{ NULL, NULL, 0, NULL },
173
{ NULL, revKSC5601, 8223, NULL }, /* KSC5601 */
175
{ NULL, NULL, 0, NULL },
178
{ NULL, revJIS0212, 6066, NULL }, /* X0212 */
180
{ NULL, NULL, 0, NULL },
182
{ NULL, NULL, 0, NULL }, /* ISO_IR_165 */
183
{ NULL, NULL, 0, CNStoUNI }, /* CNS_1 */
184
{ NULL, NULL, 0, CNStoUNI }, /* CNS_2 */
185
{ NULL, NULL, 0, CNStoUNI }, /* CNS_3 */
186
{ NULL, NULL, 0, CNStoUNI }, /* CNS_4 */
187
{ NULL, NULL, 0, NULL }, /* CNS_5 */
188
{ NULL, NULL, 0, NULL }, /* CNS_6 */
189
{ NULL, NULL, 0, NULL }, /* CNS_7 */
190
{ NULL, NULL, 0, NULL }, /* JIS X 0213-2000 Plane 1 */
191
{ NULL, NULL, 0, NULL }, /* JIS X 0213-2000 Plane 2 */
193
{ NULL, revBIG5, 13702, NULL } /* BIG5 */
195
{ NULL, NULL, 0, NULL }
199
public ic_t RevUNI( ic_t ic, byte *cset )
203
if( revTable[ (int)*cset ].map ){
204
if( 0 < (res = BinarySearch( revTable[ (int)*cset ].map,
205
revTable[ (int)*cset ].size,
210
} else if( revTable[ (int)*cset ].conv ){
211
return (*revTable[ (int)*cset ].conv)( ic, cset );
212
} else if( revTable[ (int)*cset ].directmap ){
213
if( 0x20 <= ic && ic < 0x80 ){
214
if( (ic_t)0 != (res = revTable[ (int)*cset ].directmap[ ic - 0x20 ]) ){
225
public void ConvertToUNI( i_str_t *istr )
229
for( i = 0 ; NOSET != istr[ i ].charset ; i++ ){
230
if( istr[ i ].charset < UNICODE )
231
istr[ i ].c = RevUNI( istr[ i ].c, &istr[ i ].charset );