1 |
/* wptUTF8.cpp - UTF8 conversation |
/* wptUTF8.cpp - UTF8 conversation |
2 |
* Copyright (C) 1994, 1998-2001 Free Software Foundation, Inc. |
* Copyright (C) 1994, 1998-2001 Free Software Foundation, Inc. |
3 |
* Copyright (C) 2002, 2004 Timo Schulz |
* Copyright (C) 2002, 2004 Timo Schulz |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
6 |
* |
* |
7 |
* WinPT is free software; you can redistribute it and/or modify |
* WinPT is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
* (at your option) any later version. |
11 |
* |
* |
12 |
* WinPT is distributed in the hope that it will be useful, |
* WinPT is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
16 |
* |
* |
17 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
18 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
19 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
20 |
*/ |
*/ |
21 |
|
|
22 |
|
#ifdef HAVE_CONFIG_H |
23 |
|
#include <config.h> |
24 |
|
#endif |
25 |
|
|
26 |
#include <windows.h> |
#include <windows.h> |
27 |
#include <stdlib.h> |
#include <windows.h> |
28 |
|
#include <stdlib.h> |
29 |
#include <stdio.h> |
#include <stdio.h> |
30 |
#include <string.h> |
#include <string.h> |
31 |
#include <ctype.h> |
#include <ctype.h> |
32 |
|
|
33 |
#include "wptTypes.h" |
#include "wptTypes.h" |
34 |
#include "wptErrors.h" |
#include "wptErrors.h" |
35 |
|
|
36 |
static u16 koi8_unicode[128] = { |
static u16 koi8_unicode[128] = { |
75 |
static const char *active_charset_name = "iso-8859-1"; |
static const char *active_charset_name = "iso-8859-1"; |
76 |
static u16 *active_charset = NULL; |
static u16 *active_charset = NULL; |
77 |
static int no_translation = 0; |
static int no_translation = 0; |
78 |
|
|
79 |
static int |
static int |
80 |
ascii_strcasecmp( const char *a, const char *b ) |
ascii_strcasecmp( const char *a, const char *b ) |
81 |
{ |
{ |
82 |
if( a == b ) |
if( a == b ) |
83 |
return 0; |
return 0; |
84 |
|
|
85 |
for (; *a && *b; a++, b++) { |
for (; *a && *b; a++, b++) { |
86 |
if (*a != *b && toupper(*a) != toupper(*b)) |
if (*a != *b && toupper(*a) != toupper(*b)) |
87 |
break; |
break; |
88 |
} |
} |
89 |
|
|
90 |
return *a == *b? 0 : (toupper (*a) - toupper (*b)); |
return *a == *b? 0 : (toupper (*a) - toupper (*b)); |
91 |
} /* ascii_strcasecmp */ |
} /* ascii_strcasecmp */ |
92 |
|
|
93 |
int |
int |
94 |
set_native_charset( const char *newset ) |
set_native_charset( const char *newset ) |
95 |
{ |
{ |
96 |
if( !ascii_strcasecmp( newset, "iso-8859-1" ) ) { |
if( !ascii_strcasecmp( newset, "iso-8859-1" ) ) { |
97 |
active_charset_name = "iso-8859-1"; |
active_charset_name = "iso-8859-1"; |
98 |
no_translation = 0; |
no_translation = 0; |
99 |
active_charset = NULL; |
active_charset = NULL; |
100 |
} |
} |
101 |
else if( !ascii_strcasecmp( newset, "iso-8859-2" ) ) { |
else if( !ascii_strcasecmp( newset, "iso-8859-2" ) ) { |
102 |
active_charset_name = "iso-8859-2"; |
active_charset_name = "iso-8859-2"; |
103 |
no_translation = 0; |
no_translation = 0; |
104 |
active_charset = latin2_unicode; |
active_charset = latin2_unicode; |
105 |
} |
} |
106 |
else if( !ascii_strcasecmp( newset, "koi8-r" ) ) { |
else if( !ascii_strcasecmp( newset, "koi8-r" ) ) { |
114 |
no_translation = 1; |
no_translation = 1; |
115 |
active_charset = NULL; |
active_charset = NULL; |
116 |
} |
} |
117 |
else |
else |
118 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
119 |
|
|
120 |
return 0; |
return 0; |
121 |
} /* set_native_charset */ |
} /* set_native_charset */ |
122 |
|
|
123 |
const char* |
const char* |
124 |
get_native_charset( void ) |
get_native_charset( void ) |
125 |
{ |
{ |
126 |
return active_charset_name; |
return active_charset_name; |
127 |
} /* get_native_charset */ |
} /* get_native_charset */ |
128 |
|
|
140 |
|
|
141 |
if (no_translation) |
if (no_translation) |
142 |
buffer = strdup( string ); |
buffer = strdup( string ); |
143 |
else if( active_charset ) { |
else if( active_charset ) { |
144 |
for(s=(byte*)string; *s; s++ ) { |
for(s=(byte*)string; *s; s++ ) { |
145 |
length++; |
length++; |
146 |
if( *s & 0x80 ) |
if( *s & 0x80 ) |
147 |
length += 2; /* we may need 3 bytes */ |
length += 2; /* we may need 3 bytes */ |
148 |
} |
} |
149 |
buffer = (char *)malloc( length + 1 ); |
buffer = (char *)malloc( length + 1 ); |
159 |
*p++ = 0x80 | ( (val >> 6) & 0x3f ); |
*p++ = 0x80 | ( (val >> 6) & 0x3f ); |
160 |
*p++ = 0x80 | ( val & 0x3f ); |
*p++ = 0x80 | ( val & 0x3f ); |
161 |
} |
} |
162 |
} |
} |
163 |
else |
else |
164 |
*p++ = *s; |
*p++ = *s; |
165 |
} |
} |
166 |
*p = 0; |
*p = 0; |
167 |
} |
} |
168 |
else { |
else { |
169 |
for(s=(byte*)string; *s; s++ ) { |
for(s=(byte*)string; *s; s++ ) { |
170 |
length++; |
length++; |
171 |
if( *s & 0x80 ) |
if( *s & 0x80 ) |
172 |
length++; |
length++; |
173 |
} |
} |
174 |
buffer = (char*)malloc( length + 1 ); |
buffer = (char*)malloc( length + 1 ); |
177 |
*p++ = 0xc0 | ((*s >> 6) & 3); |
*p++ = 0xc0 | ((*s >> 6) & 3); |
178 |
*p++ = 0x80 | ( *s & 0x3f ); |
*p++ = 0x80 | ( *s & 0x3f ); |
179 |
} |
} |
180 |
else |
else |
181 |
*p++ = *s; |
*p++ = *s; |
182 |
} |
} |
183 |
*p = 0; |
*p = 0; |
184 |
} |
} |
185 |
|
|
186 |
return buffer; |
return buffer; |
187 |
} /* native_to_utf8 */ |
} /* native_to_utf8 */ |
188 |
|
|
189 |
/**************** |
/**************** |
190 |
* Convert string, which is in UTF8 to native encoding. illegal |
* Convert string, which is in UTF8 to native encoding. illegal |
191 |
* encodings by some "\xnn" and quote all control characters. A |
* encodings by some "\xnn" and quote all control characters. A |
192 |
* character with value DELIM will always be quoted, it must be a |
* character with value DELIM will always be quoted, it must be a |
193 |
* vanilla ASCII character. |
* vanilla ASCII character. |
194 |
*/ |
*/ |
195 |
char * |
char * |
196 |
utf8_to_native( const char *string, size_t length, int delim ) |
utf8_to_native( const char *string, size_t length, int delim ) |
197 |
{ |
{ |
198 |
int nleft; |
int nleft; |
199 |
int i; |
int i; |
200 |
byte encbuf[8]; |
byte encbuf[8]; |
201 |
int encidx; |
int encidx; |
202 |
const byte *s; |
const byte *s; |
203 |
size_t n; |
size_t n; |
204 |
byte *buffer = NULL, *p = NULL; |
byte *buffer = NULL, *p = NULL; |
205 |
unsigned long val = 0; |
unsigned long val = 0; |
206 |
size_t slen; |
size_t slen; |
207 |
int resync = 0; |
int resync = 0; |
208 |
|
|
209 |
/* 1. pass (p==NULL): count the extended utf-8 characters */ |
/* 1. pass (p==NULL): count the extended utf-8 characters */ |
210 |
/* 2. pass (p!=NULL): create string */ |
/* 2. pass (p!=NULL): create string */ |
211 |
for( ;; ) { |
for( ;; ) { |
212 |
for( slen=length, nleft=encidx=0, n=0, s=(byte*)string; slen; s++, slen-- ) { |
for( slen=length, nleft=encidx=0, n=0, s=(byte*)string; slen; s++, slen-- ) { |
213 |
if( resync ) { |
if( resync ) { |
214 |
if( !(*s < 128 || (*s >= 0xc0 && *s <= 0xfd)) ) { |
if( !(*s < 128 || (*s >= 0xc0 && *s <= 0xfd)) ) { |
215 |
/* still invalid */ |
/* still invalid */ |
216 |
if( p ) { |
if( p ) { |
217 |
sprintf((char*)p, "\\x%02x", *s ); |
sprintf((char*)p, "\\x%02x", *s ); |
218 |
p += 4; |
p += 4; |
219 |
} |
} |
220 |
n += 4; |
n += 4; |
221 |
continue; |
continue; |
222 |
} |
} |
223 |
resync = 0; |
resync = 0; |
224 |
} |
} |
225 |
if( !nleft ) { |
if( !nleft ) { |
226 |
if( !(*s & 0x80) ) { /* plain ascii */ |
if( !(*s & 0x80) ) { /* plain ascii */ |
227 |
if( *s < 0x20 || *s == 0x7f || *s == delim) { |
if( *s < 0x20 || *s == 0x7f || *s == delim) { |
228 |
n++; |
n++; |
229 |
if( p ) |
if( p ) |
230 |
*p++ = '\\'; |
*p++ = '\\'; |
231 |
switch( *s ) { |
switch( *s ) { |
232 |
case '\n': n++; if( p ) *p++ = 'n'; break; |
case '\n': n++; if( p ) *p++ = 'n'; break; |
233 |
case '\r': n++; if( p ) *p++ = 'r'; break; |
case '\r': n++; if( p ) *p++ = 'r'; break; |
234 |
case '\f': n++; if( p ) *p++ = 'f'; break; |
case '\f': n++; if( p ) *p++ = 'f'; break; |
235 |
case '\v': n++; if( p ) *p++ = 'v'; break; |
case '\v': n++; if( p ) *p++ = 'v'; break; |
236 |
case '\b': n++; if( p ) *p++ = 'b'; break; |
case '\b': n++; if( p ) *p++ = 'b'; break; |
237 |
case 0 : n++; if( p ) *p++ = '0'; break; |
case 0 : n++; if( p ) *p++ = '0'; break; |
238 |
default: |
default: |
239 |
n += 3; |
n += 3; |
240 |
if ( p ) { |
if ( p ) { |
241 |
sprintf( (char*)p, "x%02x", *s ); |
sprintf( (char*)p, "x%02x", *s ); |
242 |
p += 3; |
p += 3; |
243 |
} |
} |
244 |
break; |
break; |
245 |
} |
} |
246 |
} |
} |
247 |
else { |
else { |
248 |
if( p ) *p++ = *s; |
if( p ) *p++ = *s; |
249 |
n++; |
n++; |
250 |
} |
} |
251 |
} |
} |
252 |
else if( (*s & 0xe0) == 0xc0 ) { /* 110x xxxx */ |
else if( (*s & 0xe0) == 0xc0 ) { /* 110x xxxx */ |
253 |
val = *s & 0x1f; |
val = *s & 0x1f; |
254 |
nleft = 1; |
nleft = 1; |
255 |
encidx = 0; |
encidx = 0; |
256 |
encbuf[encidx++] = *s; |
encbuf[encidx++] = *s; |
257 |
} |
} |
258 |
else if( (*s & 0xf0) == 0xe0 ) { /* 1110 xxxx */ |
else if( (*s & 0xf0) == 0xe0 ) { /* 1110 xxxx */ |
259 |
val = *s & 0x0f; |
val = *s & 0x0f; |
260 |
nleft = 2; |
nleft = 2; |
261 |
encidx = 0; |
encidx = 0; |
262 |
encbuf[encidx++] = *s; |
encbuf[encidx++] = *s; |
263 |
} |
} |
264 |
else if( (*s & 0xf8) == 0xf0 ) { /* 1111 0xxx */ |
else if( (*s & 0xf8) == 0xf0 ) { /* 1111 0xxx */ |
265 |
val = *s & 0x07; |
val = *s & 0x07; |
266 |
nleft = 3; |
nleft = 3; |
267 |
encidx = 0; |
encidx = 0; |
268 |
encbuf[encidx++] = *s; |
encbuf[encidx++] = *s; |
269 |
} |
} |
270 |
else if( (*s & 0xfc) == 0xf8 ) { /* 1111 10xx */ |
else if( (*s & 0xfc) == 0xf8 ) { /* 1111 10xx */ |
271 |
val = *s & 0x03; |
val = *s & 0x03; |
272 |
nleft = 4; |
nleft = 4; |
273 |
encidx = 0; |
encidx = 0; |
274 |
encbuf[encidx++] = *s; |
encbuf[encidx++] = *s; |
275 |
} |
} |
276 |
else if( (*s & 0xfe) == 0xfc ) { /* 1111 110x */ |
else if( (*s & 0xfe) == 0xfc ) { /* 1111 110x */ |
277 |
val = *s & 0x01; |
val = *s & 0x01; |
278 |
nleft = 5; |
nleft = 5; |
279 |
encidx = 0; |
encidx = 0; |
280 |
encbuf[encidx++] = *s; |
encbuf[encidx++] = *s; |
281 |
} |
} |
282 |
else { /* invalid encoding: print as \xnn */ |
else { /* invalid encoding: print as \xnn */ |
283 |
if( p ) { |
if( p ) { |
284 |
sprintf((char*)p, "\\x%02x", *s ); |
sprintf((char*)p, "\\x%02x", *s ); |
285 |
p += 4; |
p += 4; |
286 |
} |
} |
287 |
n += 4; |
n += 4; |
288 |
resync = 1; |
resync = 1; |
289 |
} |
} |
290 |
} |
} |
291 |
else if( *s < 0x80 || *s >= 0xc0 ) { /* invalid */ |
else if( *s < 0x80 || *s >= 0xc0 ) { /* invalid */ |
292 |
if( p ) { |
if( p ) { |
293 |
for(i=0; i < encidx; i++ ) { |
for(i=0; i < encidx; i++ ) { |
294 |
sprintf((char*)p, "\\x%02x", encbuf[i] ); |
sprintf((char*)p, "\\x%02x", encbuf[i] ); |
295 |
p += 4; |
p += 4; |
296 |
} |
} |
297 |
sprintf((char*)p, "\\x%02x", *s ); |
sprintf((char*)p, "\\x%02x", *s ); |
298 |
p += 4; |
p += 4; |
299 |
} |
} |
300 |
n += 4 + 4*encidx; |
n += 4 + 4*encidx; |
301 |
nleft = 0; |
nleft = 0; |
302 |
encidx = 0; |
encidx = 0; |
303 |
resync = 1; |
resync = 1; |
304 |
} |
} |
305 |
else { |
else { |
306 |
encbuf[encidx++] = *s; |
encbuf[encidx++] = *s; |
307 |
val <<= 6; |
val <<= 6; |
308 |
val |= *s & 0x3f; |
val |= *s & 0x3f; |
309 |
if( !--nleft ) { /* ready */ |
if( !--nleft ) { /* ready */ |
310 |
if (no_translation) { |
if (no_translation) { |
311 |
if( p ) { |
if( p ) { |
312 |
for(i=0; i < encidx; i++ ) |
for(i=0; i < encidx; i++ ) |
313 |
*p++ = encbuf[i]; |
*p++ = encbuf[i]; |
314 |
} |
} |
315 |
n += encidx; |
n += encidx; |
316 |
encidx = 0; |
encidx = 0; |
317 |
} |
} |
318 |
else if( active_charset ) { /* table lookup */ |
else if( active_charset ) { /* table lookup */ |
319 |
for(i=0; i < 128; i++ ) { |
for(i=0; i < 128; i++ ) { |
320 |
if( active_charset[i] == val ) |
if( active_charset[i] == val ) |
321 |
break; |
break; |
322 |
} |
} |
323 |
if( i < 128 ) { /* we can print this one */ |
if( i < 128 ) { /* we can print this one */ |
324 |
if( p ) *p++ = i+128; |
if( p ) *p++ = i+128; |
325 |
n++; |
n++; |
326 |
} |
} |
327 |
else { /* we do not have a translation: print utf8 */ |
else { /* we do not have a translation: print utf8 */ |
328 |
if( p ) { |
if( p ) { |
329 |
for(i=0; i < encidx; i++ ) { |
for(i=0; i < encidx; i++ ) { |
330 |
sprintf((char*)p, "\\x%02x", encbuf[i] ); |
sprintf((char*)p, "\\x%02x", encbuf[i] ); |
331 |
p += 4; |
p += 4; |
332 |
} |
} |
333 |
} |
} |
334 |
n += encidx*4; |
n += encidx*4; |
335 |
encidx = 0; |
encidx = 0; |
336 |
} |
} |
337 |
} |
} |
338 |
else { /* native set */ |
else { /* native set */ |
339 |
if( val >= 0x80 && val < 256 ) { |
if( val >= 0x80 && val < 256 ) { |
340 |
n++; /* we can simply print this character */ |
n++; /* we can simply print this character */ |
341 |
if( p ) *p++ = val; |
if( p ) *p++ = val; |
342 |
} |
} |
343 |
else { /* we do not have a translation: print utf8 */ |
else { /* we do not have a translation: print utf8 */ |
344 |
if( p ) { |
if( p ) { |
345 |
for(i=0; i < encidx; i++ ) { |
for(i=0; i < encidx; i++ ) { |
346 |
sprintf((char*)p, "\\x%02x", encbuf[i] ); |
sprintf((char*)p, "\\x%02x", encbuf[i] ); |
347 |
p += 4; |
p += 4; |
348 |
} |
} |
349 |
} |
} |
350 |
n += encidx*4; |
n += encidx*4; |
351 |
encidx = 0; |
encidx = 0; |
352 |
} |
} |
353 |
} |
} |
354 |
} |
} |
355 |
|
|
356 |
} |
} |
357 |
} |
} |
358 |
if( !buffer ) { /* allocate the buffer after the first pass */ |
if( !buffer ) { /* allocate the buffer after the first pass */ |
359 |
buffer = p = (byte *)malloc( n + 1 ); |
buffer = p = (byte *)malloc( n + 1 ); |
360 |
} |
} |
361 |
else { |
else { |
362 |
*p = 0; /* make a string */ |
*p = 0; /* make a string */ |
363 |
return (char*)buffer; |
return (char*)buffer; |
364 |
} |
} |
365 |
} |
} |
366 |
|
} |
367 |
|
|
368 |
|
|
369 |
|
static void |
370 |
|
conv_charset (byte *string, size_t size, int what) |
371 |
|
{ |
372 |
|
int i; |
373 |
|
|
374 |
|
if( what == 0 ) { |
375 |
|
for( i = 0; i < size; i++, string++ ) { |
376 |
|
switch( *string ) { |
377 |
|
case 0xa0: *string = 0xff; break; /* nobreakspace */ |
378 |
|
case 0xa1: *string = 0xad; break; /* exclamdown */ |
379 |
|
case 0xa2: *string = 0xbd; break; /* cent */ |
380 |
|
case 0xa3: *string = 0x9c; break; /* sterling */ |
381 |
|
case 0xa4: *string = 0xcf; break; /* currency */ |
382 |
|
case 0xa5: *string = 0xbe; break; /* yen */ |
383 |
|
case 0xa6: *string = 0xdd; break; /* brokenbar */ |
384 |
|
case 0xa7: *string = 0xf5; break; /* section */ |
385 |
|
case 0xa8: *string = 0xf9; break; /* diaeresis */ |
386 |
|
case 0xa9: *string = 0xb8; break; /* copyright */ |
387 |
|
case 0xaa: *string = 0xa6; break; /* ordfeminine */ |
388 |
|
case 0xab: *string = 0xae; break; /* guillemotleft */ |
389 |
|
case 0xac: *string = 0xaa; break; /* notsign */ |
390 |
|
case 0xad: *string = 0xf0; break; /* hyphen */ |
391 |
|
case 0xae: *string = 0xa9; break; /* registered */ |
392 |
|
case 0xaf: *string = 0xee; break; /* macron */ |
393 |
|
case 0xb0: *string = 0xf8; break; /* degree */ |
394 |
|
case 0xb1: *string = 0xf1; break; /* plusminus */ |
395 |
|
case 0xb2: *string = 0xfd; break; /* twosuperior */ |
396 |
|
case 0xb3: *string = 0xfc; break; /* threesuperior */ |
397 |
|
case 0xb4: *string = 0xef; break; /* acute */ |
398 |
|
case 0xb5: *string = 0xe6; break; /* mu */ |
399 |
|
case 0xb6: *string = 0xf4; break; /* paragraph */ |
400 |
|
case 0xb7: *string = 0xfa; break; /* periodcentered */ |
401 |
|
case 0xb8: *string = 0xf7; break; /* cedilla */ |
402 |
|
case 0xb9: *string = 0xfb; break; /* onesuperior */ |
403 |
|
case 0xba: *string = 0xa7; break; /* masculine */ |
404 |
|
case 0xbb: *string = 0xaf; break; /* guillemotright */ |
405 |
|
case 0xbc: *string = 0xac; break; /* onequarter */ |
406 |
|
case 0xbd: *string = 0xab; break; /* onehalf */ |
407 |
|
case 0xbe: *string = 0xf3; break; /* threequarters */ |
408 |
|
case 0xbf: *string = 0xa8; break; /* questiondown */ |
409 |
|
case 0xc0: *string = 0xb7; break; /* Agrave */ |
410 |
|
case 0xc1: *string = 0xb5; break; /* Aacute */ |
411 |
|
case 0xc2: *string = 0xb6; break; /* Acircumflex */ |
412 |
|
case 0xc3: *string = 0xc7; break; /* Atilde */ |
413 |
|
case 0xc4: *string = 0x8e; break; /* Adiaeresis */ |
414 |
|
case 0xc5: *string = 0x8f; break; /* Aring */ |
415 |
|
case 0xc6: *string = 0x92; break; /* AE */ |
416 |
|
case 0xc7: *string = 0x80; break; /* Ccedilla */ |
417 |
|
case 0xc8: *string = 0xd4; break; /* Egrave */ |
418 |
|
case 0xc9: *string = 0x90; break; /* Eacute */ |
419 |
|
case 0xca: *string = 0xd2; break; /* Ecircumflex */ |
420 |
|
case 0xcb: *string = 0xd3; break; /* Ediaeresis */ |
421 |
|
case 0xcc: *string = 0xde; break; /* Igrave */ |
422 |
|
case 0xcd: *string = 0xd6; break; /* Iacute */ |
423 |
|
case 0xce: *string = 0xd7; break; /* Icircumflex */ |
424 |
|
case 0xcf: *string = 0xd8; break; /* Idiaeresis */ |
425 |
|
case 0xd0: *string = 0xd1; break; /* Eth */ |
426 |
|
case 0xd1: *string = 0xa5; break; /* Ntilde */ |
427 |
|
case 0xd2: *string = 0xe3; break; /* Ograve */ |
428 |
|
case 0xd3: *string = 0xe0; break; /* Oacute */ |
429 |
|
case 0xd4: *string = 0xe2; break; /* Ocircumflex */ |
430 |
|
case 0xd5: *string = 0xe5; break; /* Otilde */ |
431 |
|
case 0xd6: *string = 0x99; break; /* Odiaeresis */ |
432 |
|
case 0xd7: *string = 0x9e; break; /* multiply */ |
433 |
|
case 0xd8: *string = 0x9d; break; /* Ooblique */ |
434 |
|
case 0xd9: *string = 0xeb; break; /* Ugrave */ |
435 |
|
case 0xda: *string = 0xe9; break; /* Uacute */ |
436 |
|
case 0xdb: *string = 0xea; break; /* Ucircumflex */ |
437 |
|
case 0xdc: *string = 0x9a; break; /* Udiaeresis */ |
438 |
|
case 0xdd: *string = 0xed; break; /* Yacute */ |
439 |
|
case 0xde: *string = 0xe8; break; /* Thorn */ |
440 |
|
case 0xdf: *string = 0xe1; break; /* ssharp */ |
441 |
|
case 0xe0: *string = 0x85; break; /* agrave */ |
442 |
|
case 0xe1: *string = 0xa0; break; /* aacute */ |
443 |
|
case 0xe2: *string = 0x83; break; /* acircumflex */ |
444 |
|
case 0xe3: *string = 0xc6; break; /* atilde */ |
445 |
|
case 0xe4: *string = 0x84; break; /* adiaeresis */ |
446 |
|
case 0xe5: *string = 0x86; break; /* aring */ |
447 |
|
case 0xe6: *string = 0x91; break; /* ae */ |
448 |
|
case 0xe7: *string = 0x87; break; /* ccedilla */ |
449 |
|
case 0xe8: *string = 0x8a; break; /* egrave */ |
450 |
|
case 0xe9: *string = 0x82; break; /* eacute */ |
451 |
|
case 0xea: *string = 0x88; break; /* ecircumflex */ |
452 |
|
case 0xeb: *string = 0x89; break; /* ediaeresis */ |
453 |
|
case 0xec: *string = 0x8d; break; /* igrave */ |
454 |
|
case 0xed: *string = 0xa1; break; /* iacute */ |
455 |
|
case 0xee: *string = 0x8c; break; /* icircumflex */ |
456 |
|
case 0xef: *string = 0x8b; break; /* idiaeresis */ |
457 |
|
case 0xf0: *string = 0xd0; break; /* eth */ |
458 |
|
case 0xf1: *string = 0xa4; break; /* ntilde */ |
459 |
|
case 0xf2: *string = 0x95; break; /* ograve */ |
460 |
|
case 0xf3: *string = 0xa2; break; /* oacute */ |
461 |
|
case 0xf4: *string = 0x93; break; /* ocircumflex */ |
462 |
|
case 0xf5: *string = 0xe4; break; /* otilde */ |
463 |
|
case 0xf6: *string = 0x94; break; /* odiaeresis */ |
464 |
|
case 0xf7: *string = 0xf6; break; /* division */ |
465 |
|
case 0xf8: *string = 0x9b; break; /* oslash */ |
466 |
|
case 0xf9: *string = 0x97; break; /* ugrave */ |
467 |
|
case 0xfa: *string = 0xa3; break; /* uacute */ |
468 |
|
case 0xfb: *string = 0x96; break; /* ucircumflex */ |
469 |
|
case 0xfc: *string = 0x81; break; /* udiaeresis */ |
470 |
|
case 0xfd: *string = 0xec; break; /* yacute */ |
471 |
|
case 0xfe: *string = 0xe7; break; /* thorn */ |
472 |
|
case 0xff: *string = 0x98; break; /* ydiaeresis */ |
473 |
|
default : break; |
474 |
|
} |
475 |
|
} |
476 |
|
} |
477 |
|
else { |
478 |
|
for( i = 0; i < size; i++, string++ ) { |
479 |
|
switch( *string ) { |
480 |
|
case 0xff: *string = 0xa0; break; |
481 |
|
case 0xad: *string = 0xa1; break; |
482 |
|
case 0xbd: *string = 0xa2; break; |
483 |
|
case 0x9c: *string = 0xa3; break; |
484 |
|
case 0xcf: *string = 0xa4; break; |
485 |
|
case 0xbe: *string = 0xa5; break; |
486 |
|
case 0xdd: *string = 0xa6; break; |
487 |
|
case 0xf5: *string = 0xa7; break; |
488 |
|
case 0xf9: *string = 0xa8; break; |
489 |
|
case 0xb8: *string = 0xa9; break; |
490 |
|
case 0xa6: *string = 0xaa; break; |
491 |
|
case 0xae: *string = 0xab; break; |
492 |
|
case 0xaa: *string = 0xac; break; |
493 |
|
case 0xf0: *string = 0xad; break; |
494 |
|
case 0xa9: *string = 0xae; break; |
495 |
|
case 0xee: *string = 0xaf; break; |
496 |
|
case 0xf8: *string = 0xb0; break; |
497 |
|
case 0xf1: *string = 0xb1; break; |
498 |
|
case 0xfd: *string = 0xb2; break; |
499 |
|
case 0xfc: *string = 0xb3; break; |
500 |
|
case 0xef: *string = 0xb4; break; |
501 |
|
case 0xe6: *string = 0xb5; break; |
502 |
|
case 0xf4: *string = 0xb6; break; |
503 |
|
case 0xfa: *string = 0xb7; break; |
504 |
|
case 0xf7: *string = 0xb8; break; |
505 |
|
case 0xfb: *string = 0xb9; break; |
506 |
|
case 0xa7: *string = 0xba; break; |
507 |
|
case 0xaf: *string = 0xbb; break; |
508 |
|
case 0xac: *string = 0xbc; break; |
509 |
|
case 0xab: *string = 0xbd; break; |
510 |
|
case 0xf3: *string = 0xbe; break; |
511 |
|
case 0xa8: *string = 0xbf; break; |
512 |
|
case 0xb7: *string = 0xc0; break; |
513 |
|
case 0xb5: *string = 0xc1; break; |
514 |
|
case 0xb6: *string = 0xc2; break; |
515 |
|
case 0xc7: *string = 0xc3; break; |
516 |
|
case 0x8e: *string = 0xc4; break; |
517 |
|
case 0x8f: *string = 0xc5; break; |
518 |
|
case 0x92: *string = 0xc6; break; |
519 |
|
case 0x80: *string = 0xc7; break; |
520 |
|
case 0xd4: *string = 0xc8; break; |
521 |
|
case 0x90: *string = 0xc9; break; |
522 |
|
case 0xd2: *string = 0xca; break; |
523 |
|
case 0xd3: *string = 0xcb; break; |
524 |
|
case 0xde: *string = 0xcc; break; |
525 |
|
case 0xd6: *string = 0xcd; break; |
526 |
|
case 0xd7: *string = 0xce; break; |
527 |
|
case 0xd8: *string = 0xcf; break; |
528 |
|
case 0xd1: *string = 0xd0; break; |
529 |
|
case 0xa5: *string = 0xd1; break; |
530 |
|
case 0xe3: *string = 0xd2; break; |
531 |
|
case 0xe0: *string = 0xd3; break; |
532 |
|
case 0xe2: *string = 0xd4; break; |
533 |
|
case 0xe5: *string = 0xd5; break; |
534 |
|
case 0x99: *string = 0xd6; break; |
535 |
|
case 0x9e: *string = 0xd7; break; |
536 |
|
case 0x9d: *string = 0xd8; break; |
537 |
|
case 0xeb: *string = 0xd9; break; |
538 |
|
case 0xe9: *string = 0xda; break; |
539 |
|
case 0xea: *string = 0xdb; break; |
540 |
|
case 0x9a: *string = 0xdc; break; |
541 |
|
case 0xed: *string = 0xdd; break; |
542 |
|
case 0xe8: *string = 0xde; break; |
543 |
|
case 0xe1: *string = 0xdf; break; |
544 |
|
case 0x85: *string = 0xe0; break; |
545 |
|
case 0xa0: *string = 0xe1; break; |
546 |
|
case 0x83: *string = 0xe2; break; |
547 |
|
case 0xc6: *string = 0xe3; break; |
548 |
|
case 0x84: *string = 0xe4; break; |
549 |
|
case 0x86: *string = 0xe5; break; |
550 |
|
case 0x91: *string = 0xe6; break; |
551 |
|
case 0x87: *string = 0xe7; break; |
552 |
|
case 0x8a: *string = 0xe8; break; |
553 |
|
case 0x82: *string = 0xe9; break; |
554 |
|
case 0x88: *string = 0xea; break; |
555 |
|
case 0x89: *string = 0xeb; break; |
556 |
|
case 0x8d: *string = 0xec; break; |
557 |
|
case 0xa1: *string = 0xed; break; |
558 |
|
case 0x8c: *string = 0xee; break; |
559 |
|
case 0x8b: *string = 0xef; break; |
560 |
|
case 0xd0: *string = 0xf0; break; |
561 |
|
case 0xa4: *string = 0xf1; break; |
562 |
|
case 0x95: *string = 0xf2; break; |
563 |
|
case 0xa2: *string = 0xf3; break; |
564 |
|
case 0x93: *string = 0xf4; break; |
565 |
|
case 0xe4: *string = 0xf5; break; |
566 |
|
case 0x94: *string = 0xf6; break; |
567 |
|
case 0xf6: *string = 0xf7; break; |
568 |
|
case 0x9b: *string = 0xf8; break; |
569 |
|
case 0x97: *string = 0xf9; break; |
570 |
|
case 0xa3: *string = 0xfa; break; |
571 |
|
case 0x96: *string = 0xfb; break; |
572 |
|
case 0x81: *string = 0xfc; break; |
573 |
|
case 0xec: *string = 0xfd; break; |
574 |
|
case 0xe7: *string = 0xfe; break; |
575 |
|
case 0x98: *string = 0xff; break; |
576 |
|
default : break; |
577 |
|
} |
578 |
|
} |
579 |
|
} |
580 |
|
} /* conv_charset */ |
581 |
|
|
582 |
|
|
583 |
|
char * |
584 |
|
utf8_to_wincp (const char * s, size_t len) |
585 |
|
{ |
586 |
|
char * decs; |
587 |
|
decs = utf8_to_native (s, len, 0); |
588 |
|
conv_charset ((byte *)decs, strlen (decs), 1); |
589 |
|
return decs; |
590 |
} |
} |
591 |
|
|
592 |
|
|
593 |
static void |
char * |
594 |
conv_charset (byte *string, size_t size, int what) |
wincp_to_utf8 (const char * s, size_t len) |
595 |
{ |
{ |
596 |
int i; |
char * encs; |
597 |
|
conv_charset ((byte *)s, len, 0); |
598 |
if( what == 0 ) { |
encs = native_to_utf8 (s); |
599 |
for( i = 0; i < size; i++, string++ ) { |
return encs; |
600 |
switch( *string ) { |
} |
601 |
case 0xa0: *string = 0xff; break; /* nobreakspace */ |
|
602 |
case 0xa1: *string = 0xad; break; /* exclamdown */ |
|
603 |
case 0xa2: *string = 0xbd; break; /* cent */ |
int |
604 |
case 0xa3: *string = 0x9c; break; /* sterling */ |
is_8bit_string (const char * str) |
605 |
case 0xa4: *string = 0xcf; break; /* currency */ |
{ |
606 |
case 0xa5: *string = 0xbe; break; /* yen */ |
size_t i; |
607 |
case 0xa6: *string = 0xdd; break; /* brokenbar */ |
|
608 |
case 0xa7: *string = 0xf5; break; /* section */ |
for (i = 0; i < strlen (str); i++) { |
609 |
case 0xa8: *string = 0xf9; break; /* diaeresis */ |
if (str[i] & 0x80) |
610 |
case 0xa9: *string = 0xb8; break; /* copyright */ |
return -1; |
611 |
case 0xaa: *string = 0xa6; break; /* ordfeminine */ |
} |
612 |
case 0xab: *string = 0xae; break; /* guillemotleft */ |
return 0; |
613 |
case 0xac: *string = 0xaa; break; /* notsign */ |
} /* is_8bit_string */ |
|
case 0xad: *string = 0xf0; break; /* hyphen */ |
|
|
case 0xae: *string = 0xa9; break; /* registered */ |
|
|
case 0xaf: *string = 0xee; break; /* macron */ |
|
|
case 0xb0: *string = 0xf8; break; /* degree */ |
|
|
case 0xb1: *string = 0xf1; break; /* plusminus */ |
|
|
case 0xb2: *string = 0xfd; break; /* twosuperior */ |
|
|
case 0xb3: *string = 0xfc; break; /* threesuperior */ |
|
|
case 0xb4: *string = 0xef; break; /* acute */ |
|
|
case 0xb5: *string = 0xe6; break; /* mu */ |
|
|
case 0xb6: *string = 0xf4; break; /* paragraph */ |
|
|
case 0xb7: *string = 0xfa; break; /* periodcentered */ |
|
|
case 0xb8: *string = 0xf7; break; /* cedilla */ |
|
|
case 0xb9: *string = 0xfb; break; /* onesuperior */ |
|
|
case 0xba: *string = 0xa7; break; /* masculine */ |
|
|
case 0xbb: *string = 0xaf; break; /* guillemotright */ |
|
|
case 0xbc: *string = 0xac; break; /* onequarter */ |
|
|
case 0xbd: *string = 0xab; break; /* onehalf */ |
|
|
case 0xbe: *string = 0xf3; break; /* threequarters */ |
|
|
case 0xbf: *string = 0xa8; break; /* questiondown */ |
|
|
case 0xc0: *string = 0xb7; break; /* Agrave */ |
|
|
case 0xc1: *string = 0xb5; break; /* Aacute */ |
|
|
case 0xc2: *string = 0xb6; break; /* Acircumflex */ |
|
|
case 0xc3: *string = 0xc7; break; /* Atilde */ |
|
|
case 0xc4: *string = 0x8e; break; /* Adiaeresis */ |
|
|
case 0xc5: *string = 0x8f; break; /* Aring */ |
|
|
case 0xc6: *string = 0x92; break; /* AE */ |
|
|
case 0xc7: *string = 0x80; break; /* Ccedilla */ |
|
|
case 0xc8: *string = 0xd4; break; /* Egrave */ |
|
|
case 0xc9: *string = 0x90; break; /* Eacute */ |
|
|
case 0xca: *string = 0xd2; break; /* Ecircumflex */ |
|
|
case 0xcb: *string = 0xd3; break; /* Ediaeresis */ |
|
|
case 0xcc: *string = 0xde; break; /* Igrave */ |
|
|
case 0xcd: *string = 0xd6; break; /* Iacute */ |
|
|
case 0xce: *string = 0xd7; break; /* Icircumflex */ |
|
|
case 0xcf: *string = 0xd8; break; /* Idiaeresis */ |
|
|
case 0xd0: *string = 0xd1; break; /* Eth */ |
|
|
case 0xd1: *string = 0xa5; break; /* Ntilde */ |
|
|
case 0xd2: *string = 0xe3; break; /* Ograve */ |
|
|
case 0xd3: *string = 0xe0; break; /* Oacute */ |
|
|
case 0xd4: *string = 0xe2; break; /* Ocircumflex */ |
|
|
case 0xd5: *string = 0xe5; break; /* Otilde */ |
|
|
case 0xd6: *string = 0x99; break; /* Odiaeresis */ |
|
|
case 0xd7: *string = 0x9e; break; /* multiply */ |
|
|
case 0xd8: *string = 0x9d; break; /* Ooblique */ |
|
|
case 0xd9: *string = 0xeb; break; /* Ugrave */ |
|
|
case 0xda: *string = 0xe9; break; /* Uacute */ |
|
|
case 0xdb: *string = 0xea; break; /* Ucircumflex */ |
|
|
case 0xdc: *string = 0x9a; break; /* Udiaeresis */ |
|
|
case 0xdd: *string = 0xed; break; /* Yacute */ |
|
|
case 0xde: *string = 0xe8; break; /* Thorn */ |
|
|
case 0xdf: *string = 0xe1; break; /* ssharp */ |
|
|
case 0xe0: *string = 0x85; break; /* agrave */ |
|
|
case 0xe1: *string = 0xa0; break; /* aacute */ |
|
|
case 0xe2: *string = 0x83; break; /* acircumflex */ |
|
|
case 0xe3: *string = 0xc6; break; /* atilde */ |
|
|
case 0xe4: *string = 0x84; break; /* adiaeresis */ |
|
|
case 0xe5: *string = 0x86; break; /* aring */ |
|
|
case 0xe6: *string = 0x91; break; /* ae */ |
|
|
case 0xe7: *string = 0x87; break; /* ccedilla */ |
|
|
case 0xe8: *string = 0x8a; break; /* egrave */ |
|
|
case 0xe9: *string = 0x82; break; /* eacute */ |
|
|
case 0xea: *string = 0x88; break; /* ecircumflex */ |
|
|
case 0xeb: *string = 0x89; break; /* ediaeresis */ |
|
|
case 0xec: *string = 0x8d; break; /* igrave */ |
|
|
case 0xed: *string = 0xa1; break; /* iacute */ |
|
|
case 0xee: *string = 0x8c; break; /* icircumflex */ |
|
|
case 0xef: *string = 0x8b; break; /* idiaeresis */ |
|
|
case 0xf0: *string = 0xd0; break; /* eth */ |
|
|
case 0xf1: *string = 0xa4; break; /* ntilde */ |
|
|
case 0xf2: *string = 0x95; break; /* ograve */ |
|
|
case 0xf3: *string = 0xa2; break; /* oacute */ |
|
|
case 0xf4: *string = 0x93; break; /* ocircumflex */ |
|
|
case 0xf5: *string = 0xe4; break; /* otilde */ |
|
|
case 0xf6: *string = 0x94; break; /* odiaeresis */ |
|
|
case 0xf7: *string = 0xf6; break; /* division */ |
|
|
case 0xf8: *string = 0x9b; break; /* oslash */ |
|
|
case 0xf9: *string = 0x97; break; /* ugrave */ |
|
|
case 0xfa: *string = 0xa3; break; /* uacute */ |
|
|
case 0xfb: *string = 0x96; break; /* ucircumflex */ |
|
|
case 0xfc: *string = 0x81; break; /* udiaeresis */ |
|
|
case 0xfd: *string = 0xec; break; /* yacute */ |
|
|
case 0xfe: *string = 0xe7; break; /* thorn */ |
|
|
case 0xff: *string = 0x98; break; /* ydiaeresis */ |
|
|
default : break; |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
for( i = 0; i < size; i++, string++ ) { |
|
|
switch( *string ) { |
|
|
case 0xff: *string = 0xa0; break; |
|
|
case 0xad: *string = 0xa1; break; |
|
|
case 0xbd: *string = 0xa2; break; |
|
|
case 0x9c: *string = 0xa3; break; |
|
|
case 0xcf: *string = 0xa4; break; |
|
|
case 0xbe: *string = 0xa5; break; |
|
|
case 0xdd: *string = 0xa6; break; |
|
|
case 0xf5: *string = 0xa7; break; |
|
|
case 0xf9: *string = 0xa8; break; |
|
|
case 0xb8: *string = 0xa9; break; |
|
|
case 0xa6: *string = 0xaa; break; |
|
|
case 0xae: *string = 0xab; break; |
|
|
case 0xaa: *string = 0xac; break; |
|
|
case 0xf0: *string = 0xad; break; |
|
|
case 0xa9: *string = 0xae; break; |
|
|
case 0xee: *string = 0xaf; break; |
|
|
case 0xf8: *string = 0xb0; break; |
|
|
case 0xf1: *string = 0xb1; break; |
|
|
case 0xfd: *string = 0xb2; break; |
|
|
case 0xfc: *string = 0xb3; break; |
|
|
case 0xef: *string = 0xb4; break; |
|
|
case 0xe6: *string = 0xb5; break; |
|
|
case 0xf4: *string = 0xb6; break; |
|
|
case 0xfa: *string = 0xb7; break; |
|
|
case 0xf7: *string = 0xb8; break; |
|
|
case 0xfb: *string = 0xb9; break; |
|
|
case 0xa7: *string = 0xba; break; |
|
|
case 0xaf: *string = 0xbb; break; |
|
|
case 0xac: *string = 0xbc; break; |
|
|
case 0xab: *string = 0xbd; break; |
|
|
case 0xf3: *string = 0xbe; break; |
|
|
case 0xa8: *string = 0xbf; break; |
|
|
case 0xb7: *string = 0xc0; break; |
|
|
case 0xb5: *string = 0xc1; break; |
|
|
case 0xb6: *string = 0xc2; break; |
|
|
case 0xc7: *string = 0xc3; break; |
|
|
case 0x8e: *string = 0xc4; break; |
|
|
case 0x8f: *string = 0xc5; break; |
|
|
case 0x92: *string = 0xc6; break; |
|
|
case 0x80: *string = 0xc7; break; |
|
|
case 0xd4: *string = 0xc8; break; |
|
|
case 0x90: *string = 0xc9; break; |
|
|
case 0xd2: *string = 0xca; break; |
|
|
case 0xd3: *string = 0xcb; break; |
|
|
case 0xde: *string = 0xcc; break; |
|
|
case 0xd6: *string = 0xcd; break; |
|
|
case 0xd7: *string = 0xce; break; |
|
|
case 0xd8: *string = 0xcf; break; |
|
|
case 0xd1: *string = 0xd0; break; |
|
|
case 0xa5: *string = 0xd1; break; |
|
|
case 0xe3: *string = 0xd2; break; |
|
|
case 0xe0: *string = 0xd3; break; |
|
|
case 0xe2: *string = 0xd4; break; |
|
|
case 0xe5: *string = 0xd5; break; |
|
|
case 0x99: *string = 0xd6; break; |
|
|
case 0x9e: *string = 0xd7; break; |
|
|
case 0x9d: *string = 0xd8; break; |
|
|
case 0xeb: *string = 0xd9; break; |
|
|
case 0xe9: *string = 0xda; break; |
|
|
case 0xea: *string = 0xdb; break; |
|
|
case 0x9a: *string = 0xdc; break; |
|
|
case 0xed: *string = 0xdd; break; |
|
|
case 0xe8: *string = 0xde; break; |
|
|
case 0xe1: *string = 0xdf; break; |
|
|
case 0x85: *string = 0xe0; break; |
|
|
case 0xa0: *string = 0xe1; break; |
|
|
case 0x83: *string = 0xe2; break; |
|
|
case 0xc6: *string = 0xe3; break; |
|
|
case 0x84: *string = 0xe4; break; |
|
|
case 0x86: *string = 0xe5; break; |
|
|
case 0x91: *string = 0xe6; break; |
|
|
case 0x87: *string = 0xe7; break; |
|
|
case 0x8a: *string = 0xe8; break; |
|
|
case 0x82: *string = 0xe9; break; |
|
|
case 0x88: *string = 0xea; break; |
|
|
case 0x89: *string = 0xeb; break; |
|
|
case 0x8d: *string = 0xec; break; |
|
|
case 0xa1: *string = 0xed; break; |
|
|
case 0x8c: *string = 0xee; break; |
|
|
case 0x8b: *string = 0xef; break; |
|
|
case 0xd0: *string = 0xf0; break; |
|
|
case 0xa4: *string = 0xf1; break; |
|
|
case 0x95: *string = 0xf2; break; |
|
|
case 0xa2: *string = 0xf3; break; |
|
|
case 0x93: *string = 0xf4; break; |
|
|
case 0xe4: *string = 0xf5; break; |
|
|
case 0x94: *string = 0xf6; break; |
|
|
case 0xf6: *string = 0xf7; break; |
|
|
case 0x9b: *string = 0xf8; break; |
|
|
case 0x97: *string = 0xf9; break; |
|
|
case 0xa3: *string = 0xfa; break; |
|
|
case 0x96: *string = 0xfb; break; |
|
|
case 0x81: *string = 0xfc; break; |
|
|
case 0xec: *string = 0xfd; break; |
|
|
case 0xe7: *string = 0xfe; break; |
|
|
case 0x98: *string = 0xff; break; |
|
|
default : break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} /* conv_charset */ |
|
|
|
|
|
|
|
|
char * |
|
|
utf8_to_wincp (const char * s, size_t len) |
|
|
{ |
|
|
char * decs; |
|
|
decs = utf8_to_native (s, len, 0); |
|
|
conv_charset ((byte *)decs, strlen (decs), 1); |
|
|
return decs; |
|
|
} |
|
|
|
|
|
|
|
|
char * |
|
|
wincp_to_utf8 (const char * s, size_t len) |
|
|
{ |
|
|
char * encs; |
|
|
conv_charset ((byte *)s, len, 0); |
|
|
encs = native_to_utf8 (s); |
|
|
return encs; |
|
|
} |
|
|
|
|
|
|
|
|
int |
|
|
is_8bit_string (const char * str) |
|
|
{ |
|
|
size_t i; |
|
|
|
|
|
for (i = 0; i < strlen (str); i++) { |
|
|
if (str[i] & 0x80) |
|
|
return -1; |
|
|
} |
|
|
return 0; |
|
|
} /* is_8bit_string */ |
|