2 * Copyright (c) 1995 Regents of the University of Michigan.
8 #if defined( DOS ) || defined( _WIN32 )
10 * This MUST precede "#ifdef STR_TRANSLATION"
11 * because STR_TRANSLATION and friends are defined in msdos.h.
16 #ifdef STR_TRANSLATION
19 static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
30 #if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) && !defined(VMS)
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <sys/param.h>
42 ldap_set_string_translators( LDAP *ld, BERTranslateProc encode_proc,
43 BERTranslateProc decode_proc )
45 ld->ld_lber_encode_translate_proc = encode_proc;
46 ld->ld_lber_decode_translate_proc = decode_proc;
51 ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable )
55 optionsp = ( entry == NULLMSG ) ? &ld->ld_lberoptions :
56 &entry->lm_ber->ber_options;
59 *optionsp |= LBER_TRANSLATE_STRINGS;
61 *optionsp &= ~LBER_TRANSLATE_STRINGS;
67 ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp,
70 if ( ld->ld_lber_decode_translate_proc == NULL ) {
71 return( LDAP_SUCCESS );
74 return( (*ld->ld_lber_decode_translate_proc)( bufp, lenp, free_input ));
79 ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp,
82 if ( ld->ld_lber_encode_translate_proc == NULL ) {
83 return( LDAP_SUCCESS );
86 return( (*ld->ld_lber_encode_translate_proc)( bufp, lenp, free_input ));
91 ** Character translation routine notes:
93 * On entry: bufp points to a "string" to be converted (not necessarily
94 * zero-terminated) and buflenp points to the length of the buffer.
96 * On exit: bufp should point to a malloc'd result. If free_input is
97 * non-zero then the original bufp will be freed. *buflenp should be
98 * set to the new length. Zero bytes in the input buffer must be left
101 * Return values: any ldap error code (LDAP_SUCCESS if all goes well).
105 #ifdef LDAP_CHARSET_8859
107 #if LDAP_CHARSET_8859 == 88591
109 #elif LDAP_CHARSET_8859 == 88592
111 #elif LDAP_CHARSET_8859 == 88593
113 #elif LDAP_CHARSET_8859 == 88594
115 #elif LDAP_CHARSET_8859 == 88595
117 #elif LDAP_CHARSET_8859 == 88596
119 #elif LDAP_CHARSET_8859 == 88597
121 #elif LDAP_CHARSET_8859 == 88598
123 #elif LDAP_CHARSET_8859 == 88599
125 #elif LDAP_CHARSET_8859 == 885910
132 * the following ISO_8859 to/afrom T.61 character set translation code is
133 * based on the code found in Enrique Silvestre Mora's iso-t61.c, found
134 * as part of this package:
135 * ftp://pereiii.uji.es/pub/uji-ftp/unix/ldap/iso-t61.translation.tar.Z
136 * Enrique is now (10/95) at this address: enrique.silvestre@uv.es
138 * changes made by mcs@umich.edu 12 October 1995:
139 * Change calling conventions of iso8859_t61() and t61_iso8859() to
140 * match libldap conventions; rename to ldap_8859_to_t61() and
141 * ldap_t61_to_8859().
142 * Change conversion routines to deal with non-zero terminated strings.
143 * ANSI-ize functions and include prototypes.
146 /* iso-t61.c - ISO-T61 translation routines (version: 0.2.1, July-1994) */
148 * Copyright (c) 1994 Enrique Silvestre Mora, Universitat Jaume I, Spain.
149 * All rights reserved.
151 * Redistribution and use in source and binary forms are permitted
152 * provided that this notice is preserved and that due credit is given
153 * to the Universitat Jaume I. The name of the University
154 * may not be used to endorse or promote products derived from this
155 * software without specific prior written permission. This software
156 * is provided ``as is'' without express or implied warranty.
164 /* Character set used: ISO 8859-1, ISO 8859-2, ISO 8859-3, ... */
165 /* #define ISO_8859 1 */
171 typedef unsigned char Byte;
172 typedef struct { Byte a, b; } Couple;
175 static Byte *c_to_hh( Byte *o, Byte c );
176 static Byte *c_to_cc( Byte *o, Couple *cc, Byte c );
177 static int hh_to_c( Byte *h );
178 static Byte *cc_to_t61( Byte *o, Byte *s );
179 #else /* NEEDPROTOS */
180 static Byte *c_to_hh();
181 static Byte *c_to_cc();
182 static int hh_to_c();
183 static Byte *cc_to_t61();
184 #endif /* NEEDPROTOS */
187 Character choosed as base in diacritics alone: NO-BREAK SPACE.
188 (The standard say it must be a blank space, 0x20.)
192 static Couple diacritic[16] = {
193 #if (ISO_8859 == 1) || (ISO_8859 == 9)
194 {0,0}, {'`',0}, {0xb4,0}, {'^',0},
195 {'~',0}, {0xaf,0}, {'(',ALONE}, {'.',ALONE},
196 {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0},
197 {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE},
198 #elif (ISO_8859 == 2)
199 {0,0}, {'`',0}, {0xb4,0}, {'^',0},
200 {'~',0}, {'-',ALONE}, {0xa2,0}, {0xff,0},
201 {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0},
202 {0,0}, {0xbd,0}, {0xb2,0}, {0xb7,0}
203 #elif (ISO_8859 == 3)
204 {0,0}, {'`',0}, {0xb4,0}, {'^',0},
205 {'~',0}, {'-',ALONE}, {0xa2,0}, {0xff,0},
206 {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0},
207 {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE}
208 #elif (ISO_8859 == 4)
209 {0,0}, {'`',0}, {0xb4,0}, {'^',0},
210 {'~',0}, {0xaf,0}, {'(',ALONE}, {0xff,0},
211 {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0},
212 {0,0}, {'"',ALONE}, {0xb2,0}, {0xb7,0}
214 {0,0}, {'`',0}, {'\'',ALONE}, {'^',0},
215 {'~',0}, {'-',ALONE}, {'(',ALONE}, {'.',ALONE},
216 {':',ALONE}, {0,0}, {'0',ALONE}, {',',ALONE},
217 {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE}
222 --- T.61 (T.51) letters with diacritics: conversion to ISO 8859-n -----
223 A, C, D, E, G, H, I, J, K,
224 L, N, O, R, S, T, U, W, Y, Z.
225 -----------------------------------------------------------------------
227 static int letter_w_diacritic[16][38] = {
229 0, 0, 0, 0, 0, 0, 0, 0, 0,
230 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
231 0, 0, 0, 0, 0, 0, 0, 0, 0,
232 0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, 0, 0xdc,0, -1, 0,
263 0xe4,0, 0, 0xeb,0, 0, 0xef,0, 0,
264 0, 0, 0xf6,0, 0, 0, 0xfc,0, 0xff,0,
265 0, 0, 0, 0, 0, 0, 0, 0, 0,
266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
267 0, 0, 0, 0, 0, 0, 0, 0, 0,
268 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
269 0xc5,0, 0, 0, 0, 0, 0, 0, 0,
270 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
271 0xe5,0, 0, 0, 0, 0, 0, 0, 0,
272 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
273 0, 0xc7,0, 0, -1, 0, 0, 0, -1,
274 -1, -1, 0, -1, -1, -1, 0, 0, 0, 0,
275 0, 0xe7,0, 0, -1, 0, 0, 0, -1,
276 -1, -1, 0, -1, -1, -1, 0, 0, 0, 0,
277 0, 0, 0, 0, 0, 0, 0, 0, 0,
278 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
279 0, 0, 0, 0, 0, 0, 0, 0, 0,
280 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
281 0, 0, 0, 0, 0, 0, 0, 0, 0,
282 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
283 0, 0, 0, 0, 0, 0, 0, 0, 0,
284 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
285 -1, 0, 0, -1, 0, 0, -1, 0, 0,
286 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
287 -1, 0, 0, -1, 0, 0, -1, 0, 0,
288 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
289 0, -1, -1, -1, 0, 0, 0, 0, 0,
290 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1,
291 0, -1, -1, -1, 0, 0, 0, 0, 0,
292 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1
293 #elif (ISO_8859 == 2)
294 0, 0, 0, 0, 0, 0, 0, 0, 0,
295 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
296 0, 0, 0, 0, 0, 0, 0, 0, 0,
297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
298 -1, 0, 0, -1, 0, 0, -1, 0, 0,
299 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
300 -1, 0, 0, -1, 0, 0, -1, 0, 0,
301 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
302 0xc1,0xc6,0, 0xc9,0, 0, 0xcd,0, 0,
303 0xc5,0xd1,0xd3,0xc0,0xa6,0, 0xda,0, 0xdd,0xac,
304 0xe1,0xe6,0, 0xe9,0, 0, 0xed,0, 0,
305 0xe5,0xf1,0xf3,0xe0,0xb6,0, 0xfa,0, 0xfd,0xbc,
306 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0,
307 0, 0, 0xd4,0, -1, 0, -1, -1, -1, 0,
308 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0,
309 0, 0, 0xf4,0, -1, 0, -1, -1, -1, 0,
310 -1, 0, 0, 0, 0, 0, -1, 0, 0,
311 0, -1, -1, 0, 0, 0, -1, 0, 0, 0,
312 -1, 0, 0, 0, 0, 0, -1, 0, 0,
313 0, -1, -1, 0, 0, 0, -1, 0, 0, 0,
314 -1, 0, 0, -1, 0, 0, -1, 0, 0,
315 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
316 -1, 0, 0, -1, 0, 0, -1, 0, 0,
317 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
318 0xc3,0, 0, 0, -1, 0, 0, 0, 0,
319 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
320 0xe3,0, 0, 0, -1, 0, 0, 0, 0,
321 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
322 0, -1, 0, -1, -1, 0, -1, 0, 0,
323 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xaf,
324 0, -1, 0, -1, -1, 0, 0, 0, 0,
325 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xbf,
326 0xc4,0, 0, 0xcb,0,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, -1, -1, -1, 0, 0, 0, -1,
421 0, -1, -1, -1, 0, 0, 0, 0, 0,
422 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1
423 #elif (ISO_8859 == 4)
424 0, 0, 0, 0, 0, 0, 0, 0, 0,
425 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
426 0, 0, 0, 0, 0, 0, 0, 0, 0,
427 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
428 -1, 0, 0, -1, 0, 0, -1, 0, 0,
429 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
430 -1, 0, 0, -1, 0, 0, -1, 0, 0,
431 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
432 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0,
433 -1, -1, -1, -1, -1, 0, 0xda,0, -1, -1,
434 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0,
435 -1, -1, -1, -1, -1, 0, 0xfa,0, -1, -1,
436 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0,
437 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0,
438 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0,
439 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0,
440 0xc3,0, 0, 0, 0, 0, 0xa5,0, 0,
441 0, -1, 0xd5,0, 0, 0, 0xdd,0, 0, 0,
442 0xe3,0, 0, 0, 0, 0, 0xb5,0, 0,
443 0, -1, 0xf5,0, 0, 0, 0xfd,0, 0, 0,
444 0xc0,0, 0, 0xaa,0, 0, 0xcf,0, 0,
445 0, 0, 0xd2,0, 0, 0, 0xde,0, 0, 0,
446 0xe0,0, 0, 0xba,0, 0, 0xef,0, 0,
447 0, 0, 0xf2,0, 0, 0, 0xfe,0, 0, 0,
448 -1, 0, 0, 0, -1, 0, 0, 0, 0,
449 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
450 -1, 0, 0, 0, -1, 0, 0, 0, 0,
451 0, 0, 0, 0, 0, 0, -1, 0,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 0, 0, 0xf9,0, 0, 0,
484 0, 0xc8,-1, -1, 0, 0, 0, 0, 0,
485 -1, -1, 0, -1, 0xa9,-1, 0, 0, 0, 0xae,
486 0, 0xe8,-1, -1, 0, 0, 0, 0, 0,
487 -1, -1, 0, -1, 0xb9,-1, 0, 0, 0, 0xbe
488 #elif (ISO_8859 == 9)
489 0, 0, 0, 0, 0, 0, 0, 0, 0,
490 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
491 0, 0, 0, 0, 0, 0, 0, 0, 0,
492 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
493 0xc0,0, 0, 0xc8,0, 0, 0xcc,0, 0,
494 0, 0, 0xd2,0, 0, 0, 0xd9,0, 0, 0,
495 0xe0,0, 0, 0xe8,0, 0, -1, 0, 0,
496 0, 0, 0xf2,0, 0, 0, 0xf9,0, 0, 0,
497 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0,
498 -1, -1, 0xd3,-1, -1, 0, 0xda,0, -1, -1,
499 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0,
500 -1, -1, 0xf3,-1, -1, 0, 0xfa,0, -1, -1,
501 0xc2,-1, 0, 0xca,-1, -1, 0xce,-1, 0,
502 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0,
503 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0,
504 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0,
505 0xc3,0, 0, 0, 0, 0, -1, 0, 0,
506 0, 0xd1,0xd5,0, 0, 0, -1, 0, 0, 0,
507 0xe3,0, 0, 0, 0, 0, -1, 0, 0,
508 0, 0xf1,0xf5,0, 0, 0, -1, 0, 0, 0,
509 -1, 0, 0, -1, 0, 0, -1, 0, 0,
510 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
511 -1, 0, 0, -1, 0, 0, 0xef,0, 0,
512 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
513 -1, 0, 0, 0, 0xd0,0, 0, 0, 0,
514 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0, 0, 0, 0, -1, 0, 0, 0,
547 -1, 0, 0, 0xea,0, 0, -1, 0, 0,
548 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
549 0, -1, -1, -1, 0, 0, 0, 0, 0,
550 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1,
551 0, -1, -1, -1, 0, 0, 0, 0, 0,
552 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1
553 #elif (ISO_8859 == 10)
554 0, 0, 0, 0, 0, 0, 0, 0, 0,
555 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
556 0, 0, 0, 0, 0, 0, 0, 0, 0,
557 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
558 -1, 0, 0, -1, 0, 0, -1, 0, 0,
559 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
560 -1, 0, 0, -1, 0, 0, -1, 0, 0,
561 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
562 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0,
563 -1, -1, 0xd3,-1, -1, 0, 0xda,0, 0xdd,-1,
564 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0,
565 -1, -1, 0xf3,-1, -1, 0, 0xfa,0, 0xfd,-1,
566 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0,
567 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0,
568 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0,
569 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0,
570 0xc3,0, 0, 0, 0, 0, 0xa5,0, 0,
571 0, -1, 0xd5,0, 0, 0, 0xd7,0, 0, 0,
572 0xe3,0, 0, 0, 0, 0, 0xb5,0, 0,
573 0, -1, 0xf5,0, 0, 0, 0xf7,0, 0, 0,
574 0xc0,0, 0, 0xa2,0, 0, 0xa4,0, 0,
575 0, 0, 0xd2,0, 0, 0, 0xae,0, 0, 0,
576 0xe0,0, 0, 0xb2,0, 0, 0xb4,0, 0,
577 0, 0, 0xf2,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, 0, 0, 0, -1, 0, 0, 0,
610 0xa1,0, 0, 0xca,0, 0, 0xc7,0, 0,
611 0, 0, 0, 0, 0, 0, 0xd9,0, 0, 0,
612 0xb1,0, 0, 0xea,0, 0, 0xe7,0, 0,
613 0, 0, 0, 0, 0, 0, 0xf9,0, 0, 0,
614 0, 0xc8,-1, -1, 0, 0, 0, 0, 0,
615 -1, -1, 0, -1, 0xaa,-1, 0, 0, 0, 0xac,
616 0, 0xe8,-1, -1, 0, 0, 0, 0, 0,
617 -1, -1, 0, -1, 0xba,-1, 0, 0, 0, 0xbc
619 0, 0, 0, 0, 0, 0, 0, 0, 0,
620 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
621 0, 0, 0, 0, 0, 0, 0, 0, 0,
622 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
623 -1, 0, 0, -1, 0, 0, -1, 0, 0,
624 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
625 -1, 0, 0, -1, 0, 0, -1, 0, 0,
626 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
627 -1, -1, 0, -1, 0, 0, -1, 0, 0,
628 -1, -1, -1, -1, -1, 0, -1, 0, -1, -1,
629 -1, -1, 0, -1, 0, 0, -1, 0, 0,
630 -1, -1, -1, -1, -1, 0, -1, 0, -1, -1,
631 -1, -1, 0, -1, -1, -1, -1, -1, 0,
632 0, 0, -1, 0, -1, 0, -1, -1, -1, 0,
633 -1, -1, 0, -1, -1, -1, -1, -1, 0,
634 0, 0, -1, 0, -1, 0, -1, -1, -1, 0,
635 -1, 0, 0, 0, 0, 0, -1, 0, 0,
636 0, -1, -1, 0, 0, 0, -1, 0, 0, 0,
637 -1, 0, 0, 0, 0, 0, -1, 0, 0,
638 0, -1, -1, 0, 0, 0, -1, 0, 0, 0,
639 -1, 0, 0, -1, 0, 0, -1, 0, 0,
640 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
641 -1, 0, 0, -1, 0, 0, -1, 0, 0,
642 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
643 -1, 0, 0, 0, -1, 0, 0, 0, 0,
644 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
645 -1, 0, 0, 0, -1, 0, 0, 0, 0,
646 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
647 0, -1, 0, -1, -1, 0, -1, 0, 0,
648 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
649 0, -1, 0, -1, -1, 0, 0, 0, 0,
650 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
651 -1, 0, 0, -1, 0, 0, -1, 0, 0,
652 0, 0, -1, 0, 0, 0, -1, 0, -1, 0,
653 -1, 0, 0, -1, 0, 0, -1, 0, 0,
654 0, 0, -1, 0, 0, 0, -1, 0, -1, 0,
655 0, 0, 0, 0, 0, 0, 0, 0, 0,
656 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
657 0, 0, 0, 0, 0, 0, 0, 0, 0,
658 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
659 -1, 0, 0, 0, 0, 0, 0, 0, 0,
660 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
661 -1, 0, 0, 0, 0, 0, 0, 0, 0,
662 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
663 0, -1, 0, 0, -1, 0, 0, 0, -1,
664 -1, -1, 0, -1, -1, -1, 0, 0, 0, 0,
665 0, -1, 0, 0, -1, 0, 0, 0, -1,
666 -1, -1, 0, -1, -1, -1, 0, 0, 0, 0,
667 0, 0, 0, 0, 0, 0, 0, 0, 0,
668 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
669 0, 0, 0, 0, 0, 0, 0, 0, 0,
670 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
671 0, 0, 0, 0, 0, 0, 0, 0, 0,
672 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
673 0, 0, 0, 0, 0, 0, 0, 0, 0,
674 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
675 -1, 0, 0, -1, 0, 0, -1, 0, 0,
676 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
677 -1, 0, 0, -1, 0, 0, -1, 0, 0,
678 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
679 0, -1, -1, -1, 0, 0, 0, 0, 0,
680 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1,
681 0, -1, -1, -1, 0, 0, 0, 0, 0,
682 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1
687 --- T.61 characters [0xA0 .. 0xBF] -----------------
689 static Couple trans_t61a_iso8859[32] = {
690 #if (ISO_8859 == 1) || (ISO_8859 == 9)
691 {'N','S'}, {0xa1,0}, {0xa2,0}, {0xa3,0},
692 {'D','O'}, {0xa5,0}, {'C','u'}, {0xa7,0},
693 {0xa4,0}, {'\'','6'},{'"','6'}, {0xab,0},
694 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
695 {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0},
696 {0xd7,0}, {0xb5,0}, {0xb6,0}, {0xb7,0},
697 {0xf7,0}, {'\'','9'},{'"','9'}, {0xbb,0},
698 {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0}
699 #elif (ISO_8859 == 2) || (ISO_8859 == 4)
700 {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'},
701 {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0},
702 {0xa4,0}, {'\'','6'},{'"','6'}, {'<','<'},
703 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
704 {0xb0,0}, {'+','-'}, {'2','S'}, {'3','S'},
705 {0xd7,0}, {'M','y'}, {'P','I'}, {'.','M'},
706 {0xf7,0}, {'\'','9'},{'"','9'}, {'>','>'},
707 {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'},
708 #elif (ISO_8859 == 3)
709 {'N','S'}, {'!','I'}, {'C','t'}, {0xa3,0},
710 {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0},
711 {0xa4,0}, {'\'','6'},{'"','6'}, {'<','<'},
712 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
713 {0xb0,0}, {'+','-'}, {0xb2,0}, {0xb3,0},
714 {0xd7,0}, {0xb5,0}, {'P','I'}, {0xb7,0},
715 {0xf7,0}, {'\'','9'},{'"','9'}, {'>','>'},
716 {'1','4'}, {0xbd,0}, {'3','4'}, {'?','I'}
717 #elif (ISO_8859 == 10)
718 {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'},
719 {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0},
720 {'C','u'}, {'\'','6'},{'"','6'}, {'<','<'},
721 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
722 {0xb0,0}, {'+','-'}, {'2','S'}, {'3','S'},
723 {'*','X'}, {'M','y'}, {'P','I'}, {0xb7,0},
724 {'-',':'}, {'\'','9'},{'"','9'}, {'>','>'},
725 {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'}
727 {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'},
728 {'D','O'}, {'Y','e'}, {'C','u'}, {'S','E'},
729 {'X','O'}, {'\'','6'},{'"','6'}, {'<','<'},
730 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
731 {'D','G'}, {'+','-'}, {'2','S'}, {'3','S'},
732 {'*','X'}, {'M','y'}, {'P','I'}, {'.','M'},
733 {'-',':'}, {'\'','9'},{'"','9'}, {'>','>'},
734 {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'}
739 --- T.61 characters [0xE0 .. 0xFF] -----------------
741 static Couple trans_t61b_iso8859[48] = {
743 {'-','M'}, {0xb9,0}, {0xae,0}, {0xa9,0},
744 {'T','M'}, {'M','8'}, {0xac,0}, {0xa6,0},
745 {0,0}, {0,0}, {0,0}, {0,0},
746 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
747 {'O','m'}, {0xc6,0}, {0xd0,0}, {0xaa,0},
748 {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
749 {'L','/'}, {0xd8,0}, {'O','E'}, {0xba,0},
750 {0xde,0}, {'T','/'}, {'N','G'}, {'\'','n'},
751 {'k','k'}, {0xe6,0}, {'d','/'}, {0xf0,0},
752 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
753 {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0},
754 {0xfe,0}, {'t','/'}, {'n','g'}, {'-','-'}
755 #elif (ISO_8859 == 2)
756 {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'},
757 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
758 {0,0}, {0,0}, {0,0}, {0,0},
759 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
760 {'O','m'}, {'A','E'}, {0xd0,0}, {'-','a'},
761 {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
762 {0xa3,0}, {'O','/'}, {'O','E'}, {'-','o'},
763 {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'},
764 {'k','k'}, {'a','e'}, {0xf0,0}, {'d','-'},
765 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
766 {0xb3,0}, {'o','/'}, {'o','e'}, {0xdf,0},
767 {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'}
768 #elif (ISO_8859 == 3)
769 {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'},
770 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
771 {0,0}, {0,0}, {0,0}, {0,0},
772 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
773 {'O','m'}, {'A','E'}, {'D','/'}, {'-','a'},
774 {0xa1,0}, {0,0}, {'I','J'}, {'L','.'},
775 {'L','/'}, {'O','/'}, {'O','E'}, {'-','o'},
776 {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'},
777 {'k','k'}, {'a','e'}, {'d','/'}, {'d','-'},
778 {0xb1,0}, {0xb9,0}, {'i','j'}, {'l','.'},
779 {'l','/'}, {'o','/'}, {'o','e'}, {0xdf,0},
780 {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'}
781 #elif (ISO_8859 == 4)
782 {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'},
783 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
784 {0,0}, {0,0}, {0,0}, {0,0},
785 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
786 {'O','m'}, {0xc6,0}, {0xd0,0}, {'-','a'},
787 {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
788 {'L','/'}, {0xd8,0}, {'O','E'}, {'-','o'},
789 {'T','H'}, {0xac,0}, {0xbd,0}, {'\'','n'},
790 {0xa2,0}, {0xe6,0}, {0xf0,0}, {'d','-'},
791 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
792 {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0},
793 {'t','h'}, {0xbc,0}, {0xbf,0}, {'-','-'}
794 #elif (ISO_8859 == 9)
795 {'-','M'}, {0xb9,0}, {0xae,0}, {0xa9,0},
796 {'T','M'}, {'M','8'}, {0xac,0}, {0xa6,0},
797 {0,0}, {0,0}, {0,0}, {0,0},
798 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
799 {'O','m'}, {0xc6,0}, {'D','/'}, {0xaa,0},
800 {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
801 {'L','/'}, {0xd8,0}, {'O','E'}, {0xba,0},
802 {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'},
803 {'k','k'}, {0xe6,0}, {'d','/'}, {'d','-'},
804 {'h','/'}, {0xfd,0}, {'i','j'}, {'l','.'},
805 {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0},
806 {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'}
807 #elif (ISO_8859 == 10)
808 {0xbd,0}, {'1','S'}, {'R','g'}, {'C','o'},
809 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
810 {0,0}, {0,0}, {0,0}, {0,0},
811 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
812 {'O','m'}, {0xc6,0}, {0xa9,0}, {'-','a'},
813 {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
814 {'L','/'}, {0xd8,0}, {'O','E'}, {'-','o'},
815 {0xde,0}, {0xab,0}, {0xaf,0}, {'\'','n'},
816 {0xff,0}, {0xe6,0}, {0xb9,0}, {0xf0,0},
817 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
818 {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0},
819 {0xfe,0}, {0xbb,0}, {0xbf,0}, {'-','-'}
821 {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'},
822 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
823 {0,0}, {0,0}, {0,0}, {0,0},
824 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
825 {'O','m'}, {'A','E'}, {'D','/'}, {'-','a'},
826 {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
827 {'L','/'}, {'O','/'}, {'O','E'}, {'-','o'},
828 {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'},
829 {'k','k'}, {'a','e'}, {'d','/'}, {'d','-'},
830 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
831 {'l','/'}, {'o','/'}, {'o','e'}, {'s','s'},
832 {'t','h'}, {'t','-'}, {'n','g'}, {'-','-'}
837 --- ISO 8859-n characters <0xA0 .. 0xFF> -------------------
840 static Couple trans_iso8859_t61[96] = {
841 {0xa0,0}, {0xa1,0}, {0xa2,0}, {0xa3,0},
842 {0xa8,0}, {0xa5,0}, {0xd7,0}, {0xa7,0},
843 {0xc8,ALONE}, {0xd3,0}, {0xe3,0}, {0xab,0},
844 {0xd6,0}, {0xff,0}, {0xd2,0}, {0xc5,ALONE},
845 {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0},
846 {0xc2,ALONE}, {0xb5,0}, {0xb6,0}, {0xb7,0},
847 {0xcb,ALONE}, {0xd1,0}, {0xeb,0}, {0xbb,0},
848 {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0},
849 {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'},
850 {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xcb,'C'},
851 {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'},
852 {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'},
853 {0xe2,0}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'},
854 {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0},
855 {0xe9,0}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'},
856 {0xc8,'U'}, {0xc2,'Y'}, {0xec,0}, {0xfb,0},
857 {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'},
858 {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xcb,'c'},
859 {0xc1,'e'}, {0xc2,'e'}, {0xc3,'e'}, {0xc8,'e'},
860 {0xc1,'i'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'},
861 {0xf3,0}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'},
862 {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0},
863 {0xf9,0}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'},
864 {0xc8,'u'}, {0xc2,'y'}, {0xfc,0}, {0xc8,'y'}
866 #elif (ISO_8859 == 2)
867 static Couple trans_iso8859_t61[96] = {
868 {0xa0,0}, {0xce,'A'}, {0xc6,ALONE}, {0xe8,0},
869 {0xa8,0}, {0xcf,'L'}, {0xc2,'S'}, {0xa7,0},
870 {0xc8,ALONE}, {0xcf,'S'}, {0xcb,'S'}, {0xcf,'T'},
871 {0xc2,'Z'}, {0xff,0}, {0xcf,'Z'}, {0xc7,'Z'},
872 {0xb0,0}, {0xce,'a'}, {0xce,ALONE}, {0xf8,0},
873 {0xc2,ALONE}, {0xcf,'l'}, {0xc2,'s'}, {0xcf,ALONE},
874 {0xcb,ALONE}, {0xcf,'s'}, {0xcb,'s'}, {0xcf,'t'},
875 {0xc2,'z'}, {0xcd,ALONE}, {0xcf,'z'}, {0xc7,'z'},
876 {0xc2,'R'}, {0xc2,'A'}, {0xc3,'A'}, {0xc6,'A'},
877 {0xc8,'A'}, {0xc2,'L'}, {0xc2,'C'}, {0xcb,'C'},
878 {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'},
879 {0xcf,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xcf,'D'},
880 {0xe2,0}, {0xc2,'N'}, {0xcf,'N'}, {0xc2,'O'},
881 {0xc3,'O'}, {0xcd,'O'}, {0xc8,'O'}, {0xb4,0},
882 {0xcf,'R'}, {0xca,'U'}, {0xc2,'U'}, {0xcd,'U'},
883 {0xc8,'U'}, {0xc2,'Y'}, {0xcb,'T'}, {0xfb,0},
884 {0xc2,'r'}, {0xc2,'a'}, {0xc3,'a'}, {0xc6,'a'},
885 {0xc8,'a'}, {0xc2,'l'}, {0xc2,'c'}, {0xcb,'c'},
886 {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'},
887 {0xcf,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xcf,'d'},
888 {0xf2,0}, {0xc2,'n'}, {0xcf,'n'}, {0xc2,'o'},
889 {0xc3,'o'}, {0xcd,'o'}, {0xc8,'o'}, {0xb8,0},
890 {0xcf,'r'}, {0xca,'u'}, {0xc2,'u'}, {0xcd,'u'},
891 {0xc8,'u'}, {0xc2,'y'}, {0xcb,'t'}, {0xc7,ALONE}
893 #elif (ISO_8859 == 3)
894 static Couple trans_iso8859_t61[96] = {
895 {0xa0,0}, {0xe4,0}, {0xc6,ALONE}, {0xa3,0},
896 {0xa8,0}, {0,0}, {0xc3,'H'}, {0xa7,0},
897 {0xc8,ALONE}, {0xc7,'I'}, {0xcb,'S'}, {0xc6,'G'},
898 {0xc3,'J'}, {0xff,0}, {0,0}, {0xc7,'Z'},
899 {0xb0,0}, {0xf4,0}, {0xb2,0}, {0xb3,0},
900 {0xc2,ALONE}, {0xb5,0}, {0xc3,'h'}, {0xb7,0},
901 {0xcb,ALONE}, {0xf5,0}, {0xcb,'s'}, {0xc6,'g'},
902 {0xc3,'j'}, {0xbd,0}, {0,0}, {0xc7,'z'},
903 {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0,0},
904 {0xc8,'A'}, {0xc7,'C'}, {0xc3,'C'}, {0xcb,'C'},
905 {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'},
906 {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'},
907 {0,0}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'},
908 {0xc3,'O'}, {0xc7,'G'}, {0xc8,'O'}, {0xb4,0},
909 {0xc3,'G'}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'},
910 {0xc8,'U'}, {0xc6,'U'}, {0xc3,'S'}, {0xfb,0},
911 {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0,0},
912 {0xc8,'a'}, {0xc7,'c'}, {0xc3,'c'}, {0xcb,'c'},
913 {0xc1,'e'}, {0xc2,'e'}, {0xc3,'e'}, {0xc8,'e'},
914 {0xc1,'i'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'},
915 {0,0}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'},
916 {0xc3,'o'}, {0xc7,'g'}, {0xc8,'o'}, {0xb8,0},
917 {0xc3,'g'}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'},
918 {0xc8,'u'}, {0xc6,'u'}, {0xc3,'s'}, {0xc7,ALONE}
920 #elif (ISO_8859 == 4)
921 static Couple trans_iso8859_t61[96] = {
922 {0xa0,0}, {0xce,'A'}, {0xf0,0}, {0xcb,'R'},
923 {0xa8,0}, {0xc4,'I'}, {0xcb,'L'}, {0xa7,0},
924 {0xc8,ALONE}, {0xcf,'S'}, {0xc5,'E'}, {0xcb,'G'},
925 {0xed,0}, {0xff,0}, {0xcf,'Z'}, {0xc5,ALONE},
926 {0xb0,0}, {0xce,'a'}, {0xce,ALONE}, {0xcb,'r'},
927 {0xc2,ALONE}, {0xc4,'i'}, {0xcb,'l'}, {0xcf,ALONE},
928 {0xcb,ALONE}, {0xcf,'s'}, {0xc5,'e'}, {0xcb,'g'},
929 {0xfd,0}, {0xee,0}, {0xcf,'z'}, {0xfe,0},
930 {0xc5,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'},
931 {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xce,'I'},
932 {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'},
933 {0xc7,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xc5,'I'},
934 {0xe2,0}, {0xcb,'N'}, {0xc5,'O'}, {0xcb,'K'},
935 {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0},
936 {0xe9,0}, {0xce,'U'}, {0xc2,'U'}, {0xc3,'U'},
937 {0xc8,'U'}, {0xc4,'U'}, {0xc5,'U'}, {0xfb,0},
938 {0xc5,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'},
939 {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xce,'i'},
940 {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'},
941 {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc5,'i'},
942 {0xf2,0}, {0xcb,'n'}, {0xc5,'o'}, {0xcb,'k'},
943 {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0},
944 {0xf9,0}, {0xce,'u'}, {0xc2,'u'}, {0xc3,'u'},
945 {0xc8,'u'}, {0xc4,'u'}, {0xc5,'u'}, {0xc7,ALONE}
947 #elif (ISO_8859 == 9)
948 static Couple trans_iso8859_t61[96] = {
949 {0xa0,0}, {0xa1,0}, {0xa2,0}, {0xa3,0},
950 {0xa8,0}, {0xa5,0}, {0xd7,0}, {0xa7,0},
951 {0xc8,ALONE}, {0xd3,0}, {0xe3,0}, {0xab,0},
952 {0xd6,0}, {0xff,0}, {0xd2,0}, {0xc5,ALONE},
953 {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0},
954 {0xc2,ALONE}, {0xb5,0}, {0xb6,0}, {0xb7,0},
955 {0xcb,ALONE}, {0xd1,0}, {0xeb,0}, {0xbb,0},
956 {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0},
957 {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'},
958 {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xcb,'C'},
959 {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'},
960 {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'},
961 {0xc6,'G'}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'},
962 {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0},
963 {0xe9,0}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'},
964 {0xc8,'U'}, {0xc7,'I'}, {0xcb,'S'}, {0xfb,0},
965 {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'},
966 {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xcb,'c'},
967 {0xc1,'e'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'},
968 {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc5,'i'},
969 {0xc6,'g'}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'},
970 {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0},
971 {0xf9,0}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'},
972 {0xc8,'u'}, {0xf5,0}, {0xcb,'s'}, {0xc8,'y'}
974 #elif (ISO_8859 == 10)
975 static Couple trans_iso8859_t61[96] = {
976 {0xa0,0}, {0xce,'A'}, {0xc5,'E'}, {0xcb,'G'},
977 {0xc5,'I'}, {0xc4,'I'}, {0xcb,'K'}, {0xa7,0},
978 {0xcb,'L'}, {0xe2,0}, {0xcf,'S'}, {0xed,0},
979 {0xcf,'Z'}, {0xff,0}, {0xc5,'U'}, {0xee,0},
980 {0xb0,0}, {0xce,'a'}, {0xc5,'e'}, {0xcb,'g'},
981 {0xc5,'i'}, {0xc4,'i'}, {0xcb,'k'}, {0xb7,0},
982 {0xcb,'l'}, {0xf2,0}, {0xcf,'s'}, {0xfd,0},
983 {0xcf,'z'}, {0xd0,0}, {0xc5,'u'}, {0xfe,0},
984 {0xc5,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'},
985 {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xce,'I'},
986 {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'},
987 {0xc7,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'},
988 {0,0}, {0xcb,'N'}, {0xc5,'O'}, {0xc2,'O'},
989 {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xc4,'U'},
990 {0xe9,0}, {0xce,'U'}, {0xc2,'U'}, {0xc3,'U'},
991 {0xc8,'U'}, {0xc2,'Y'}, {0xec,0}, {0xfb,0},
992 {0xc5,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'},
993 {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xce,'i'},
994 {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'},
995 {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'},
996 {0xf3,0}, {0xcb,'n'}, {0xc5,'o'}, {0xc2,'o'},
997 {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xc4,'u'},
998 {0xf9,0}, {0xce,'u'}, {0xc2,'u'}, {0xc3,'u'},
999 {0xc8,'u'}, {0xc2,'y'}, {0xfc,0}, {0xf0,0}
1005 c_to_hh( Byte *o, Byte c )
1009 *o++ = '{'; *o++ = 'x';
1011 *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n;
1013 *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n;
1020 c_to_cc( Byte *o, Couple *cc, Byte c )
1022 if ( (*cc).a != 0 ) {
1034 return c_to_hh( o, c );
1037 /* --- routine to convert from T.61 to ISO 8859-n --- */
1040 ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
1048 Debug( LDAP_DEBUG_TRACE, "ldap_t61_to_8859 input length: %ld\n",
1054 if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
1058 while ( (char *)s - *(char **)bufp < len ) {
1059 switch ( *s >> 4 ) {
1062 o = c_to_cc( o, &trans_t61a_iso8859[ *s - 0xA0 ], *s );
1066 case 0xD: case 0xE: case 0xF:
1067 o = c_to_cc( o, &trans_t61b_iso8859[ *s - 0xD0 ], *s );
1072 if ( (*s == 0xC0) || (*s == 0xC9) || (*s == 0xCC) ) {
1073 o = c_to_hh( o, *s++ );
1080 case 'A': c = letter_w_diacritic[n][0]; break;
1081 case 'C': c = letter_w_diacritic[n][1]; break;
1082 case 'D': c = letter_w_diacritic[n][2]; break;
1083 case 'E': c = letter_w_diacritic[n][3]; break;
1084 case 'G': c = letter_w_diacritic[n][4]; break;
1085 case 'H': c = letter_w_diacritic[n][5]; break;
1086 case 'I': c = letter_w_diacritic[n][6]; break;
1087 case 'J': c = letter_w_diacritic[n][7]; break;
1088 case 'K': c = letter_w_diacritic[n][8]; break;
1089 case 'L': c = letter_w_diacritic[n][9]; break;
1090 case 'N': c = letter_w_diacritic[n][10]; break;
1091 case 'O': c = letter_w_diacritic[n][11]; break;
1092 case 'R': c = letter_w_diacritic[n][12]; break;
1093 case 'S': c = letter_w_diacritic[n][13]; break;
1094 case 'T': c = letter_w_diacritic[n][14]; break;
1095 case 'U': c = letter_w_diacritic[n][15]; break;
1096 case 'W': c = letter_w_diacritic[n][16]; break;
1097 case 'Y': c = letter_w_diacritic[n][17]; break;
1098 case 'Z': c = letter_w_diacritic[n][18]; break;
1100 case 'a': c = letter_w_diacritic[n][19]; break;
1101 case 'c': c = letter_w_diacritic[n][20]; break;
1102 case 'd': c = letter_w_diacritic[n][21]; break;
1103 case 'e': c = letter_w_diacritic[n][22]; break;
1104 case 'g': c = letter_w_diacritic[n][23]; break;
1105 case 'h': c = letter_w_diacritic[n][24]; break;
1106 case 'i': c = letter_w_diacritic[n][25]; break;
1107 case 'j': c = letter_w_diacritic[n][26]; break;
1108 case 'k': c = letter_w_diacritic[n][27]; break;
1109 case 'l': c = letter_w_diacritic[n][28]; break;
1110 case 'n': c = letter_w_diacritic[n][29]; break;
1111 case 'o': c = letter_w_diacritic[n][30]; break;
1112 case 'r': c = letter_w_diacritic[n][31]; break;
1113 case 's': c = letter_w_diacritic[n][32]; break;
1114 case 't': c = letter_w_diacritic[n][33]; break;
1115 case 'u': c = letter_w_diacritic[n][34]; break;
1116 case 'w': c = letter_w_diacritic[n][35]; break;
1117 case 'y': c = letter_w_diacritic[n][36]; break;
1118 case 'z': c = letter_w_diacritic[n][37]; break;
1120 case ALONE: c = (( !diacritic[n].b ) ? diacritic[n].a : -1);
1131 *o++ = ( ( *s == ALONE ) ? ' ' : *s );
1136 *o++ = diacritic[n].a;
1143 *o++ = 0x1B; /* <ESC> */
1156 if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
1164 *bufp = (char *) oo;
1175 if ( (*h >= '0') && (*h <= '9') ) c = *h++ - '0';
1176 else if ( (*h >= 'A') && (*h <= 'F') ) c = *h++ - 'A' + 10;
1177 else if ( (*h >= 'a') && (*h <= 'f') ) c = *h++ - 'a' + 10;
1182 if ( (*h >= '0') && (*h <= '9') ) c |= *h - '0';
1183 else if ( (*h >= 'A') && (*h <= 'F') ) c |= *h - 'A' + 10;
1184 else if ( (*h >= 'a') && (*h <= 'f') ) c |= *h - 'a' + 10;
1192 cc_to_t61( Byte *o, Byte *s )
1196 switch ( *(s + 1) ) {
1198 case '`': c = -1; break; /* <grave-accent> */
1202 case '!': c = 0x7C; break; /* <vertical-line> */
1203 case '(': c = 0x7B; break; /* <left-curly-bracket> */
1204 case '-': c = 0xAD; break; /* <upwards-arrow> */
1205 default: c = -1; /* <grave-accent> */
1209 #if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
1210 (ISO_8859 == 4) || (ISO_8859 == 9)
1213 case '\'': c = -2; break; /* <acute-accent> */
1215 case '^': c = -3; break; /* <circumflex-acent> */
1219 case ')': c = 0x5D; break; /* <right-square-bracket> */
1220 case '>': c = 0xBB; break; /* <right-angle-quotation> */
1221 case '-': c = 0xAE; break; /* <rightwards-arrow> */
1222 default: c = -3; /* <circumflex-acent> */
1227 case '?': c = -4; break; /* <tilde> */
1229 #if (ISO_8859 == 1) || (ISO_8859 == 4) || (ISO_8859 == 9)
1230 case 0xAF: c = -5; break; /* <macron> */
1235 case '-': c = 0xFF; break; /* <soft-hyphen> */
1236 case '<': c = 0xAC; break; /* <leftwards arrow> */
1237 case '+': c = 0xB1; break; /* <plus-minus> */
1238 case 'd': c = 0xF3; break; /* <eth> */
1239 default: c = -5; /* <macron> */
1243 #if (ISO_8859 == 2) || (ISO_8859 == 3)
1244 case 0xA2: c = -6; break; /* <breve> */
1248 if ( *s == '<' ) c = 0x5B; /* <left-square-bracket> */
1249 else c = -6; /* <breve> */
1252 #if (ISO_8859 == 2) || (ISO_8859 == 3) || (ISO_8859 == 4)
1253 case 0xFF: c = -7; break; /* <dot-accent> */
1258 case 'i': c = 0xF5; break; /* <dotless-i> */
1259 case 'L': c = 0xE7; break; /* <L-middle-dot> */
1260 case 'l': c = 0xF7; break; /* <l-middle-dot> */
1261 default: c = -7; /* <dot-accent> */
1265 #if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
1266 (ISO_8859 == 4) || (ISO_8859 == 9)
1267 case 0xA8: c = -8; break; /* <diaeresis> */
1271 if ( *s == '-') c = 0xB8; /* <division-sign> */
1272 else c = -8; /* <diaeresis> */
1275 #if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
1276 (ISO_8859 == 4) || (ISO_8859 == 9) || (ISO_8859 == 10)
1279 case '0': c = -10; break; /* <ring-above> */
1281 #if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
1282 (ISO_8859 == 4) || (ISO_8859 == 9)
1285 case ',': c = -11; break; /* <cedilla> */
1290 case '"': c = -13; break; /* <double-acute-accent> */
1292 #if (ISO_8859 == 2) || (ISO_8859 == 4)
1295 case ';': c = -14; break; /* <ogonek> */
1297 #if (ISO_8859 == 2) || (ISO_8859 == 4)
1298 case 0xB7: c = -15; break; /* <caron> */
1302 if ( *s == '!' ) c = 0x7D; /* <left-curly-bracket> */
1306 if ( *s == '<' ) c = 0xAB; /* <left-angle-quotation> */
1307 else c = -15; /* <caron> */
1312 case '/': c = 0x5C; break; /* <reverse-solidus> */
1313 case 'D': c = 0xE2; break; /* <D-stroke> */
1314 case 'd': c = 0xF2; break; /* <d-stroke> */
1315 case 'H': c = 0xE4; break; /* <H-stroke> */
1316 case 'h': c = 0xF4; break; /* <h-stroke> */
1317 case 'L': c = 0xE8; break; /* <L-stroke> */
1318 case 'l': c = 0xF8; break; /* <l-stroke> */
1319 case 'O': c = 0xE9; break; /* <O-stroke> */
1320 case 'o': c = 0xF9; break; /* <o-stroke> */
1321 case 'T': c = 0xED; break; /* <T-stroke> */
1322 case 't': c = 0xFD; break; /* <t-stroke> */
1327 if ( *s == '1' ) c = 0xBD; /* <one-half> */
1332 case '1': c = 0xBC; break; /* <one-quarter> */
1333 case '3': c = 0xBE; break; /* <three-quarters> */
1339 case '\'': c = 0xA9; break; /* <left-single-quotation> */
1340 case '"': c = 0xAA; break; /* <left-double-quotation> */
1346 case '1': c = 0xDC; break; /* <one-eighth> */
1347 case '3': c = 0xDD; break; /* <three-eighths> */
1348 case '5': c = 0xDE; break; /* <five-eighths> */
1349 case '7': c = 0xDF; break; /* <seven-eighths> */
1350 case 'M': c = 0xD5; break; /* <eighth-note> */
1356 case '\'': c = 0xB9; break; /* <right-single-quotation> */
1357 case '"': c = 0xBA; break; /* <right-double-quotation> */
1362 if ( *s == 'A' ) c = -10; /* <ring-above> + <A> */
1367 case '-': c = 0xE3; break; /* <femenine-ordinal-a> */
1368 case 'a': c = -10; break; /* <ring-above> + <a> */
1373 if ( *s == 'B' ) c = 0xD7; /* <broken-bar> */
1377 if ( *s == 'N' ) c = 0xA6; /* <number-sign> */
1381 if ( *s == 'P' ) c = 0xA3; /* <pound-sign> */
1386 case 'S': c = 0xA7; break; /* <section-sign> */
1387 case 'A': c = 0xE1; break; /* <AE> */
1388 case 'O': c = 0xEA; break; /* <OE> */
1394 case 'a': c = 0xF1; break; /* <ae> */
1395 case 'o': c = 0xFA; break; /* <oe> */
1396 case 'Y': c = 0xA5; break; /* <yen-sign> */
1402 case 'D': c = 0xB0; break; /* <degree-sign> */
1403 case 'N': c = 0xEE; break; /* <Eng> */
1409 case 'R': c = 0xD2; break; /* <registered-sign> */
1410 case 'n': c = 0xFE; break; /* <eng> */
1415 if ( *s == 'T' ) c = 0xEC; /* <Thorn> */
1419 if ( *s == 't' ) c = 0xFC; /* <thorn> */
1424 case 'P': c = 0xB6; break; /* <pilcrow-sign> */
1425 case '!': c = 0xA1; break; /* <inverted-exclamation> */
1426 case '?': c = 0xBF; break; /* <inverted-question> */
1431 if ( *s == 'I' ) c = 0xE6; /* <IJ> */
1435 if ( *s == 'i' ) c = 0xF6; /* <ij> */
1439 if ( *s == 'k' ) c = 0xF0; /* <kra> */
1444 case '.': c = 0xB7; break; /* <middle-dot> */
1445 case '-': c = 0xD0; break; /* <em-dash> */
1446 case 'T': c = 0xD4; break; /* <trade-mark-sign> */
1452 case '\'': /* <macron> RFC 1345 */
1453 case ' ': c = -5; break; /* <macron> */
1454 case 'O': c = 0xE0; break; /* <Ohm sign> */
1459 if ( *s == '\'' ) c = 0xEF; /* <n-preceded-by-apostrophe> */
1464 case 'D': c = 0xA4; break; /* <dollar-sign> */
1465 case 'N': c = 0xD6; break; /* <not-sign> */
1471 case 'C': c = 0xD3; break; /* <copyright-sign> */
1472 case '-': c = 0xEB; break; /* <masculine-ordinal-o> */
1478 case '1': c = 0xD1; break; /* <superscript-1> */
1479 case '2': c = 0xB2; break; /* <superscript-2> */
1480 case '3': c = 0xB3; break; /* <superscript-3> */
1481 case 'N': c = 0xA0; break; /* <no-break-space> */
1486 if ( *s == 's' ) c = 0xFB; /* <sharp-s> */
1490 if ( *s == 'C' ) c = 0xA2; /* <cent-sign> */
1494 if ( *s == 'C' ) c = 0xA8; /* <currency-sign> */
1498 if ( *s == '-' ) c = 0xAF; /* <downwards-arrow> */
1502 if ( *s == '*' ) c = 0xB4; /* <multiplication-sign> */
1506 if ( *s == 'M' ) c = 0xB5; /* <micro-sign> */
1520 case 'A': c = letter_w_diacritic[n][0]; break;
1521 case 'C': c = letter_w_diacritic[n][1]; break;
1522 case 'D': c = letter_w_diacritic[n][2]; break;
1523 case 'E': c = letter_w_diacritic[n][3]; break;
1524 case 'G': c = letter_w_diacritic[n][4]; break;
1525 case 'H': c = letter_w_diacritic[n][5]; break;
1526 case 'I': c = letter_w_diacritic[n][6]; break;
1527 case 'J': c = letter_w_diacritic[n][7]; break;
1528 case 'K': c = letter_w_diacritic[n][8]; break;
1529 case 'L': c = letter_w_diacritic[n][9]; break;
1530 case 'N': c = letter_w_diacritic[n][10]; break;
1531 case 'O': c = letter_w_diacritic[n][11]; break;
1532 case 'R': c = letter_w_diacritic[n][12]; break;
1533 case 'S': c = letter_w_diacritic[n][13]; break;
1534 case 'T': c = letter_w_diacritic[n][14]; break;
1535 case 'U': c = letter_w_diacritic[n][15]; break;
1536 case 'W': c = letter_w_diacritic[n][16]; break;
1537 case 'Y': c = letter_w_diacritic[n][17]; break;
1538 case 'Z': c = letter_w_diacritic[n][18]; break;
1540 case 'a': c = letter_w_diacritic[n][19]; break;
1541 case 'c': c = letter_w_diacritic[n][20]; break;
1542 case 'd': c = letter_w_diacritic[n][21]; break;
1543 case 'e': c = letter_w_diacritic[n][22]; break;
1544 case 'g': c = letter_w_diacritic[n][23]; break;
1545 case 'h': c = letter_w_diacritic[n][24]; break;
1546 case 'i': c = letter_w_diacritic[n][25]; break;
1547 case 'j': c = letter_w_diacritic[n][26]; break;
1548 case 'k': c = letter_w_diacritic[n][27]; break;
1549 case 'l': c = letter_w_diacritic[n][28]; break;
1550 case 'n': c = letter_w_diacritic[n][29]; break;
1551 case 'o': c = letter_w_diacritic[n][30]; break;
1552 case 'r': c = letter_w_diacritic[n][31]; break;
1553 case 's': c = letter_w_diacritic[n][32]; break;
1554 case 't': c = letter_w_diacritic[n][33]; break;
1555 case 'u': c = letter_w_diacritic[n][34]; break;
1556 case 'w': c = letter_w_diacritic[n][35]; break;
1557 case 'y': c = letter_w_diacritic[n][36]; break;
1558 case 'z': c = letter_w_diacritic[n][37]; break;
1561 case ' ': c = -1; break;
1570 *o++ = ( ( (*s == ' ') || (*s == '\'') ) ? ALONE : *s );
1575 /* --- routine to convert from ISO 8859-n to T.61 --- */
1578 ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
1580 Byte *s, *oo, *o, *aux;
1585 Debug( LDAP_DEBUG_TRACE, "ldap_8859_to_t61 input length: %ld\n",
1591 if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
1595 while ( (char *)s - *(char **)bufp < len ) {
1601 case '^': *o++ = 0xC3; *o++ = ALONE; s++; break;
1605 if ( (c = hh_to_c( s )) != -1 ) {
1612 default: *o++ = *s++;
1619 case '`': *o++ = 0xC1; *o++ = ALONE; s++; break;
1620 case '~': *o++ = 0xC4; *o++ = ALONE; s++; break;
1624 if ( *(s + 2) == '}' ) {
1625 if ( (aux = cc_to_t61( o, s )) != NULL ) {
1631 } else if ( (*(s + 3) == '}') && ( (*s == 'x') || (*s == 'X') ) &&
1632 ( (c = hh_to_c( s + 1 )) != -1 ) ) {
1646 case 4: case 5: case 6: case 7:
1650 case 5: case 6: case 7:
1651 # if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
1652 (ISO_8859 == 4) || (ISO_8859 == 9) || (ISO_8859 == 10)
1653 if ( (*(cc = &trans_iso8859_t61[ *s - 0xA0 ])).a ) {
1655 if ( (*cc).b ) *o++ = (*cc).b;
1670 if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
1678 *bufp = (char *) oo;
1684 #ifdef NOT_NEEDED_IN_LIBLDAP /* mcs@umich.edu 12 Oct 1995 */
1685 /* --- routine to convert "escaped" (\hh) characters to 8bits --- */
1687 void convert_escaped_to_8bit( s )
1695 if ( (c = hh_to_c( ++s )) != -1 ) {
1706 /* --- routine to convert 8bits characters to the "escaped" (\hh) form --- */
1708 char *convert_8bit_to_escaped( s )
1714 if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
1724 *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n;
1726 *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n;
1733 if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
1738 return( (char *)oo );
1741 /* --- routine to convert from T.61 to printable characters --- */
1744 printable characters [RFC 1488]: 'A'..'Z', 'a'..'z', '0'..'9',
1745 '\'', '(', ')', '+', ',', '-', '.', '/', ':', '?, ' '.
1747 that conversion is language dependent.
1750 static Couple last_t61_printabled[32] = {
1751 {0,0}, {'A','E'}, {'D',0}, {0,0},
1752 {'H',0}, {0,0}, {'I','J'}, {'L',0},
1753 {'L',0}, {'O',0}, {'O','E'}, {0,0},
1754 {'T','H'}, {'T',0}, {'N','G'}, {'n',0},
1755 {'k',0}, {'a','e'}, {'d',0}, {'d',0},
1756 {'h',0}, {'i',0}, {'i','j'}, {'l',0},
1757 {'l',0}, {'o',0}, {'o','e'}, {'s','s'},
1758 {'t','h'}, {'t',0}, {'n','g'}, {0,0}
1761 char *t61_printable( s )
1768 if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
1773 if ( ( (*s >= 'A') && (*s <= 'Z') ) ||
1774 ( (*s >= 'a') && (*s <= 'z') ) ||
1775 ( (*s >= '0') && (*s <= '9') ) ||
1776 ( (*s >= '\'') && (*s <= ')') ) ||
1777 ( (*s >= '+') && (*s <= '/') ) ||
1778 ( *s == '?' ) || ( *s == ' ' ) )
1782 if ( (*(cc = &last_t61_printabled[ *s - 0xE0 ])).a ) {
1784 if ( (*cc).b ) *o++ = (*cc).b;
1787 else if ( (*s >> 4) == 0xC ) {
1789 case 0xCA: /* ring */
1790 switch ( *(s + 1) ) {
1791 case 'A': *o++ = 'A'; *o++ = 'A'; s++; break; /* Swedish */
1792 case 'a': *o++ = 'a'; *o++ = 'a'; s++; break; /* Swedish */
1796 case 0xC8: /* diaeresis */
1797 switch ( *(s + 1) ) {
1798 case 'Y': *o++ = 'I'; *o++ = 'J'; s++; break; /* Dutch */
1799 case 'y': *o++ = 'i'; *o++ = 'j'; s++; break; /* Dutch */
1811 if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
1816 return( (char *)oo );
1818 #endif /* NOT_NEEDED_IN_LIBLDAP */ /* mcs@umich.edu 12 Oct 1995 */
1820 #endif /* LDAP_CHARSET_8859 */
1821 #endif /* STR_TRANSLATION */