1 /* 2 * Copyright (c) 2001 by Sun Microsystems, Inc. 3 * All rights reserved. 4 */ 5 6 /* 7 * The contents of this file are subject to the Netscape Public 8 * License Version 1.1 (the "License"); you may not use this file 9 * except in compliance with the License. You may obtain a copy of 10 * the License at http://www.mozilla.org/NPL/ 11 * 12 * Software distributed under the License is distributed on an "AS 13 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 14 * implied. See the License for the specific language governing 15 * rights and limitations under the License. 16 * 17 * The Original Code is Mozilla Communicator client code, released 18 * March 31, 1998. 19 * 20 * The Initial Developer of the Original Code is Netscape 21 * Communications Corporation. Portions created by Netscape are 22 * Copyright (C) 1998-1999 Netscape Communications Corporation. All 23 * Rights Reserved. 24 * 25 * Contributor(s): 26 */ 27 /* 28 * Copyright (c) 1995 Regents of the University of Michigan. 29 * All rights reserved. 30 */ 31 /* 32 * charset.c 33 */ 34 35 #include "ldap-int.h" 36 37 #ifdef STR_TRANSLATION 38 39 void 40 ldap_set_string_translators( LDAP *ld, BERTranslateProc encode_proc, 41 BERTranslateProc decode_proc ) 42 { 43 if ( ld == NULL ) { 44 if ( !nsldapi_initialized ) { 45 nsldapi_initialize_defaults(); 46 } 47 ld = &nsldapi_ld_defaults; 48 } 49 50 if ( NSLDAPI_VALID_LDAP_POINTER( ld )) { 51 ld->ld_lber_encode_translate_proc = encode_proc; 52 ld->ld_lber_decode_translate_proc = decode_proc; 53 } 54 } 55 56 57 void 58 ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable ) 59 { 60 char *optionsp; 61 62 if ( ld == NULL ) { 63 if ( !nsldapi_initialized ) { 64 nsldapi_initialize_defaults(); 65 } 66 ld = &nsldapi_ld_defaults; 67 } 68 69 optionsp = ( entry == NULLMSG ) ? &ld->ld_lberoptions : 70 &entry->lm_ber->ber_options; 71 72 if ( enable ) { 73 *optionsp |= LBER_OPT_TRANSLATE_STRINGS; 74 } else { 75 *optionsp &= ~LBER_OPT_TRANSLATE_STRINGS; 76 } 77 } 78 79 80 int 81 ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp, 82 int free_input ) 83 { 84 ber_len_t length = (ber_len_t)*lenp; 85 86 if ( ld->ld_lber_decode_translate_proc == NULL ) { 87 return( LDAP_SUCCESS ); 88 } 89 90 return( (*ld->ld_lber_decode_translate_proc)( bufp, &length, free_input )); 91 } 92 93 94 int 95 ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp, 96 int free_input ) 97 { 98 ber_len_t length = (ber_len_t)*lenp; 99 100 if ( ld->ld_lber_encode_translate_proc == NULL ) { 101 return( LDAP_SUCCESS ); 102 } 103 104 return( (*ld->ld_lber_encode_translate_proc)( bufp, &length, free_input )); 105 } 106 107 108 /* 109 ** Character translation routine notes: 110 * 111 * On entry: bufp points to a "string" to be converted (not necessarily 112 * zero-terminated) and buflenp points to the length of the buffer. 113 * 114 * On exit: bufp should point to a malloc'd result. If free_input is 115 * non-zero then the original bufp will be freed. *buflenp should be 116 * set to the new length. Zero bytes in the input buffer must be left 117 * as zero bytes. 118 * 119 * Return values: any ldap error code (LDAP_SUCCESS if all goes well). 120 */ 121 122 123 #ifdef LDAP_CHARSET_8859 124 125 #if LDAP_CHARSET_8859 == 88591 126 #define ISO_8859 1 127 #elif LDAP_CHARSET_8859 == 88592 128 #define ISO_8859 2 129 #elif LDAP_CHARSET_8859 == 88593 130 #define ISO_8859 3 131 #elif LDAP_CHARSET_8859 == 88594 132 #define ISO_8859 4 133 #elif LDAP_CHARSET_8859 == 88595 134 #define ISO_8859 5 135 #elif LDAP_CHARSET_8859 == 88596 136 #define ISO_8859 6 137 #elif LDAP_CHARSET_8859 == 88597 138 #define ISO_8859 7 139 #elif LDAP_CHARSET_8859 == 88598 140 #define ISO_8859 8 141 #elif LDAP_CHARSET_8859 == 88599 142 #define ISO_8859 9 143 #elif LDAP_CHARSET_8859 == 885910 144 #define ISO_8859 10 145 #else 146 #define ISO_8859 0 147 #endif 148 149 /* 150 * the following ISO_8859 to/afrom T.61 character set translation code is 151 * based on the code found in Enrique Silvestre Mora's iso-t61.c, found 152 * as part of this package: 153 * ftp://pereiii.uji.es/pub/uji-ftp/unix/ldap/iso-t61.translation.tar.Z 154 * Enrique is now (10/95) at this address: enrique.silvestre@uv.es 155 * 156 * changes made by mcs@umich.edu 12 October 1995: 157 * Change calling conventions of iso8859_t61() and t61_iso8859() to 158 * match libldap conventions; rename to ldap_8859_to_t61() and 159 * ldap_t61_to_8859(). 160 * Change conversion routines to deal with non-zero terminated strings. 161 * ANSI-ize functions and include prototypes. 162 */ 163 164 /* iso-t61.c - ISO-T61 translation routines (version: 0.2.1, July-1994) */ 165 /* 166 * Copyright (c) 1994 Enrique Silvestre Mora, Universitat Jaume I, Spain. 167 * All rights reserved. 168 * 169 * Redistribution and use in source and binary forms are permitted 170 * provided that this notice is preserved and that due credit is given 171 * to the Universitat Jaume I. The name of the University 172 * may not be used to endorse or promote products derived from this 173 * software without specific prior written permission. This software 174 * is provided ``as is'' without express or implied warranty. 175 */ 176 177 178 #include <stdio.h> 179 #include <stdlib.h> 180 #include <string.h> 181 182 /* Character set used: ISO 8859-1, ISO 8859-2, ISO 8859-3, ... */ 183 /* #define ISO_8859 1 */ 184 185 #ifndef ISO_8859 186 # define ISO_8859 0 187 #endif 188 189 typedef unsigned char Byte; 190 typedef struct { Byte a, b; } Couple; 191 192 #ifdef NEEDPROTOS 193 static Byte *c_to_hh( Byte *o, Byte c ); 194 static Byte *c_to_cc( Byte *o, Couple *cc, Byte c ); 195 static int hh_to_c( Byte *h ); 196 static Byte *cc_to_t61( Byte *o, Byte *s ); 197 #else /* NEEDPROTOS */ 198 static Byte *c_to_hh(); 199 static Byte *c_to_cc(); 200 static int hh_to_c(); 201 static Byte *cc_to_t61(); 202 #endif /* NEEDPROTOS */ 203 204 /* 205 Character choosed as base in diacritics alone: NO-BREAK SPACE. 206 (The standard say it must be a blank space, 0x20.) 207 */ 208 #define ALONE 0xA0 209 210 static Couple diacritic[16] = { 211 #if (ISO_8859 == 1) || (ISO_8859 == 9) 212 {0,0}, {'`',0}, {0xb4,0}, {'^',0}, 213 {'~',0}, {0xaf,0}, {'(',ALONE}, {'.',ALONE}, 214 {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0}, 215 {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE}, 216 #elif (ISO_8859 == 2) 217 {0,0}, {'`',0}, {0xb4,0}, {'^',0}, 218 {'~',0}, {'-',ALONE}, {0xa2,0}, {0xff,0}, 219 {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0}, 220 {0,0}, {0xbd,0}, {0xb2,0}, {0xb7,0} 221 #elif (ISO_8859 == 3) 222 {0,0}, {'`',0}, {0xb4,0}, {'^',0}, 223 {'~',0}, {'-',ALONE}, {0xa2,0}, {0xff,0}, 224 {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0}, 225 {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE} 226 #elif (ISO_8859 == 4) 227 {0,0}, {'`',0}, {0xb4,0}, {'^',0}, 228 {'~',0}, {0xaf,0}, {'(',ALONE}, {0xff,0}, 229 {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0}, 230 {0,0}, {'"',ALONE}, {0xb2,0}, {0xb7,0} 231 #else 232 {0,0}, {'`',0}, {'\'',ALONE}, {'^',0}, 233 {'~',0}, {'-',ALONE}, {'(',ALONE}, {'.',ALONE}, 234 {':',ALONE}, {0,0}, {'0',ALONE}, {',',ALONE}, 235 {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE} 236 #endif 237 }; 238 239 /* 240 --- T.61 (T.51) letters with diacritics: conversion to ISO 8859-n ----- 241 A, C, D, E, G, H, I, J, K, 242 L, N, O, R, S, T, U, W, Y, Z. 243 ----------------------------------------------------------------------- 244 */ 245 static int letter_w_diacritic[16][38] = { 246 #if (ISO_8859 == 1) 247 0, 0, 0, 0, 0, 0, 0, 0, 0, 248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 249 0, 0,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f,0, 0, 280 0, 0, 0xd6,0, 0, 0, 0xdc,0, -1, 0, 281 0xe4,0, 0, 0xeb,0, 0, 0xef,0, 0, 282 0, 0, 0xf6,0, 0, 0, 0xfc,0, 0xff,0, 283 0, 0, 0, 0, 0, 0, 0, 0, 0, 284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 285 0, 0, 0, 0, 0, 0, 0, 0, 0, 286 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 287 0xc5,0, 0, 0, 0, 0, 0, 0, 0, 288 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 289 0xe5,0, 0, 0, 0, 0, 0, 0, 0, 290 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 291 0, 0xc7,0, 0, -1, 0, 0, 0, -1, 292 -1, -1, 0, -1, -1, -1, 0, 0, 0, 0, 293 0, 0xe7,0, 0, -1, 0, 0, 0, -1, 294 -1, -1, 0, -1, -1, -1, 0, 0, 0, 0, 295 0, 0, 0, 0, 0, 0, 0, 0, 0, 296 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 297 0, 0, 0, 0, 0, 0, 0, 0, 0, 298 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 299 0, 0, 0, 0, 0, 0, 0, 0, 0, 300 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 301 0, 0, 0, 0, 0, 0, 0, 0, 0, 302 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 303 -1, 0, 0, -1, 0, 0, -1, 0, 0, 304 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 305 -1, 0, 0, -1, 0, 0, -1, 0, 0, 306 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 307 0, -1, -1, -1, 0, 0, 0, 0, 0, 308 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1, 309 0, -1, -1, -1, 0, 0, 0, 0, 0, 310 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1 311 #elif (ISO_8859 == 2) 312 0, 0, 0, 0, 0, 0, 0, 0, 0, 313 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 314 0, 0, 0, 0, 0, 0, 0, 0, 0, 315 0, 0, 0, 0, 0, 0, 0, 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 -1, 0, 0, -1, 0, 0, -1, 0, 0, 319 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 320 0xc1,0xc6,0, 0xc9,0, 0, 0xcd,0, 0, 321 0xc5,0xd1,0xd3,0xc0,0xa6,0, 0xda,0, 0xdd,0xac, 322 0xe1,0xe6,0, 0xe9,0, 0, 0xed,0, 0, 323 0xe5,0xf1,0xf3,0xe0,0xb6,0, 0xfa,0, 0xfd,0xbc, 324 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0, 325 0, 0, 0xd4,0, -1, 0, -1, -1, -1, 0, 326 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0, 327 0, 0, 0xf4,0, -1, 0, -1, -1, -1, 0, 328 -1, 0, 0, 0, 0, 0, -1, 0, 0, 329 0, -1, -1, 0, 0, 0, -1, 0, 0, 0, 330 -1, 0, 0, 0, 0, 0, -1, 0, 0, 331 0, -1, -1, 0, 0, 0, -1, 0, 0, 0, 332 -1, 0, 0, -1, 0, 0, -1, 0, 0, 333 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 334 -1, 0, 0, -1, 0, 0, -1, 0, 0, 335 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 336 0xc3,0, 0, 0, -1, 0, 0, 0, 0, 337 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 338 0xe3,0, 0, 0, -1, 0, 0, 0, 0, 339 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 340 0, -1, 0, -1, -1, 0, -1, 0, 0, 341 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xaf, 342 0, -1, 0, -1, -1, 0, 0, 0, 0, 343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 438 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1, 439 0, -1, -1, -1, 0, 0, 0, 0, 0, 440 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1 441 #elif (ISO_8859 == 4) 442 0, 0, 0, 0, 0, 0, 0, 0, 0, 443 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 444 0, 0, 0, 0, 0, 0, 0, 0, 0, 445 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 446 -1, 0, 0, -1, 0, 0, -1, 0, 0, 447 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 448 -1, 0, 0, -1, 0, 0, -1, 0, 0, 449 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 450 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0, 451 -1, -1, -1, -1, -1, 0, 0xda,0, -1, -1, 452 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0, 453 -1, -1, -1, -1, -1, 0, 0xfa,0, -1, -1, 454 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0, 455 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0, 456 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0, 457 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0, 458 0xc3,0, 0, 0, 0, 0, 0xa5,0, 0, 459 0, -1, 0xd5,0, 0, 0, 0xdd,0, 0, 0, 460 0xe3,0, 0, 0, 0, 0, 0xb5,0, 0, 461 0, -1, 0xf5,0, 0, 0, 0xfd,0, 0, 0, 462 0xc0,0, 0, 0xaa,0, 0, 0xcf,0, 0, 463 0, 0, 0xd2,0, 0, 0, 0xde,0, 0, 0, 464 0xe0,0, 0, 0xba,0, 0, 0xef,0, 0, 465 0, 0, 0xf2,0, 0, 0, 0xfe,0, 0, 0, 466 -1, 0, 0, 0, -1, 0, 0, 0, 0, 467 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 468 -1, 0, 0, 0, -1, 0, 0, 0, 0, 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 0xe7,0, 0, 501 0, 0, 0, 0, 0, 0, 0xf9,0, 0, 0, 502 0, 0xc8,-1, -1, 0, 0, 0, 0, 0, 503 -1, -1, 0, -1, 0xa9,-1, 0, 0, 0, 0xae, 504 0, 0xe8,-1, -1, 0, 0, 0, 0, 0, 505 -1, -1, 0, -1, 0xb9,-1, 0, 0, 0, 0xbe 506 #elif (ISO_8859 == 9) 507 0, 0, 0, 0, 0, 0, 0, 0, 0, 508 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 509 0, 0, 0, 0, 0, 0, 0, 0, 0, 510 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 511 0xc0,0, 0, 0xc8,0, 0, 0xcc,0, 0, 512 0, 0, 0xd2,0, 0, 0, 0xd9,0, 0, 0, 513 0xe0,0, 0, 0xe8,0, 0, -1, 0, 0, 514 0, 0, 0xf2,0, 0, 0, 0xf9,0, 0, 0, 515 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0, 516 -1, -1, 0xd3,-1, -1, 0, 0xda,0, -1, -1, 517 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0, 518 -1, -1, 0xf3,-1, -1, 0, 0xfa,0, -1, -1, 519 0xc2,-1, 0, 0xca,-1, -1, 0xce,-1, 0, 520 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0, 521 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0, 522 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0, 523 0xc3,0, 0, 0, 0, 0, -1, 0, 0, 524 0, 0xd1,0xd5,0, 0, 0, -1, 0, 0, 0, 525 0xe3,0, 0, 0, 0, 0, -1, 0, 0, 526 0, 0xf1,0xf5,0, 0, 0, -1, 0, 0, 0, 527 -1, 0, 0, -1, 0, 0, -1, 0, 0, 528 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 529 -1, 0, 0, -1, 0, 0, 0xef,0, 0, 530 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 531 -1, 0, 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, 0, 0, -1, 0, 0, 564 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 565 -1, 0, 0, 0xea,0, 0, -1, 0, 0, 566 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 567 0, -1, -1, -1, 0, 0, 0, 0, 0, 568 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1, 569 0, -1, -1, -1, 0, 0, 0, 0, 0, 570 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1 571 #elif (ISO_8859 == 10) 572 0, 0, 0, 0, 0, 0, 0, 0, 0, 573 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 574 0, 0, 0, 0, 0, 0, 0, 0, 0, 575 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 576 -1, 0, 0, -1, 0, 0, -1, 0, 0, 577 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 578 -1, 0, 0, -1, 0, 0, -1, 0, 0, 579 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 580 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0, 581 -1, -1, 0xd3,-1, -1, 0, 0xda,0, 0xdd,-1, 582 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0, 583 -1, -1, 0xf3,-1, -1, 0, 0xfa,0, 0xfd,-1, 584 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0, 585 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0, 586 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0, 587 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0, 588 0xc3,0, 0, 0, 0, 0, 0xa5,0, 0, 589 0, -1, 0xd5,0, 0, 0, 0xd7,0, 0, 0, 590 0xe3,0, 0, 0, 0, 0, 0xb5,0, 0, 591 0, -1, 0xf5,0, 0, 0, 0xf7,0, 0, 0, 592 0xc0,0, 0, 0xa2,0, 0, 0xa4,0, 0, 593 0, 0, 0xd2,0, 0, 0, 0xae,0, 0, 0, 594 0xe0,0, 0, 0xb2,0, 0,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 0, 0, 0, 0, 0, 627 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 628 0xa1,0, 0, 0xca,0, 0, 0xc7,0, 0, 629 0, 0, 0, 0, 0, 0, 0xd9,0, 0, 0, 630 0xb1,0, 0, 0xea,0, 0, 0xe7,0, 0, 631 0, 0, 0, 0, 0, 0, 0xf9,0, 0, 0, 632 0, 0xc8,-1, -1, 0, 0, 0, 0, 0, 633 -1, -1, 0, -1, 0xaa,-1, 0, 0, 0, 0xac, 634 0, 0xe8,-1, -1, 0, 0, 0, 0, 0, 635 -1, -1, 0, -1, 0xba,-1, 0, 0, 0, 0xbc 636 #else 637 0, 0, 0, 0, 0, 0, 0, 0, 0, 638 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 639 0, 0, 0, 0, 0, 0, 0, 0, 0, 640 0, 0, 0, 0, 0, 0, 0, 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, -1, 0, 0, -1, 0, 0, 644 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 645 -1, -1, 0, -1, 0, 0, -1, 0, 0, 646 -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, 647 -1, -1, 0, -1, 0, 0, -1, 0, 0, 648 -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, 649 -1, -1, 0, -1, -1, -1, -1, -1, 0, 650 0, 0, -1, 0, -1, 0, -1, -1, -1, 0, 651 -1, -1, 0, -1, -1, -1, -1, -1, 0, 652 0, 0, -1, 0, -1, 0, -1, -1, -1, 0, 653 -1, 0, 0, 0, 0, 0, -1, 0, 0, 654 0, -1, -1, 0, 0, 0, -1, 0, 0, 0, 655 -1, 0, 0, 0, 0, 0, -1, 0, 0, 656 0, -1, -1, 0, 0, 0, -1, 0, 0, 0, 657 -1, 0, 0, -1, 0, 0, -1, 0, 0, 658 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 659 -1, 0, 0, -1, 0, 0, -1, 0, 0, 660 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 661 -1, 0, 0, 0, -1, 0, 0, 0, 0, 662 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 663 -1, 0, 0, 0, -1, 0, 0, 0, 0, 664 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 665 0, -1, 0, -1, -1, 0, -1, 0, 0, 666 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 667 0, -1, 0, -1, -1, 0, 0, 0, 0, 668 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 669 -1, 0, 0, -1, 0, 0, -1, 0, 0, 670 0, 0, -1, 0, 0, 0, -1, 0, -1, 0, 671 -1, 0, 0, -1, 0, 0, -1, 0, 0, 672 0, 0, -1, 0, 0, 0, -1, 0, -1, 0, 673 0, 0, 0, 0, 0, 0, 0, 0, 0, 674 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 675 0, 0, 0, 0, 0, 0, 0, 0, 0, 676 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 677 -1, 0, 0, 0, 0, 0, 0, 0, 0, 678 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 679 -1, 0, 0, 0, 0, 0, 0, 0, 0, 680 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 681 0, -1, 0, 0, -1, 0, 0, 0, -1, 682 -1, -1, 0, -1, -1, -1, 0, 0, 0, 0, 683 0, -1, 0, 0, -1, 0, 0, 0, -1, 684 -1, -1, 0, -1, -1, -1, 0, 0, 0, 0, 685 0, 0, 0, 0, 0, 0, 0, 0, 0, 686 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 687 0, 0, 0, 0, 0, 0, 0, 0, 0, 688 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 689 0, 0, 0, 0, 0, 0, 0, 0, 0, 690 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 691 0, 0, 0, 0, 0, 0, 0, 0, 0, 692 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 693 -1, 0, 0, -1, 0, 0, -1, 0, 0, 694 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 695 -1, 0, 0, -1, 0, 0, -1, 0, 0, 696 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 697 0, -1, -1, -1, 0, 0, 0, 0, 0, 698 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1, 699 0, -1, -1, -1, 0, 0, 0, 0, 0, 700 -1, -1, 0, -1, -1, -1, 0, 0, 0, -1 701 #endif 702 }; 703 704 /* 705 --- T.61 characters [0xA0 .. 0xBF] ----------------- 706 */ 707 static Couple trans_t61a_iso8859[32] = { 708 #if (ISO_8859 == 1) || (ISO_8859 == 9) 709 {'N','S'}, {0xa1,0}, {0xa2,0}, {0xa3,0}, 710 {'D','O'}, {0xa5,0}, {'C','u'}, {0xa7,0}, 711 {0xa4,0}, {'\'','6'},{'"','6'}, {0xab,0}, 712 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'}, 713 {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0}, 714 {0xd7,0}, {0xb5,0}, {0xb6,0}, {0xb7,0}, 715 {0xf7,0}, {'\'','9'},{'"','9'}, {0xbb,0}, 716 {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0} 717 #elif (ISO_8859 == 2) || (ISO_8859 == 4) 718 {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'}, 719 {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0}, 720 {0xa4,0}, {'\'','6'},{'"','6'}, {'<','<'}, 721 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'}, 722 {0xb0,0}, {'+','-'}, {'2','S'}, {'3','S'}, 723 {0xd7,0}, {'M','y'}, {'P','I'}, {'.','M'}, 724 {0xf7,0}, {'\'','9'},{'"','9'}, {'>','>'}, 725 {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'}, 726 #elif (ISO_8859 == 3) 727 {'N','S'}, {'!','I'}, {'C','t'}, {0xa3,0}, 728 {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0}, 729 {0xa4,0}, {'\'','6'},{'"','6'}, {'<','<'}, 730 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'}, 731 {0xb0,0}, {'+','-'}, {0xb2,0}, {0xb3,0}, 732 {0xd7,0}, {0xb5,0}, {'P','I'}, {0xb7,0}, 733 {0xf7,0}, {'\'','9'},{'"','9'}, {'>','>'}, 734 {'1','4'}, {0xbd,0}, {'3','4'}, {'?','I'} 735 #elif (ISO_8859 == 10) 736 {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'}, 737 {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0}, 738 {'C','u'}, {'\'','6'},{'"','6'}, {'<','<'}, 739 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'}, 740 {0xb0,0}, {'+','-'}, {'2','S'}, {'3','S'}, 741 {'*','X'}, {'M','y'}, {'P','I'}, {0xb7,0}, 742 {'-',':'}, {'\'','9'},{'"','9'}, {'>','>'}, 743 {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'} 744 #else 745 {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'}, 746 {'D','O'}, {'Y','e'}, {'C','u'}, {'S','E'}, 747 {'X','O'}, {'\'','6'},{'"','6'}, {'<','<'}, 748 {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'}, 749 {'D','G'}, {'+','-'}, {'2','S'}, {'3','S'}, 750 {'*','X'}, {'M','y'}, {'P','I'}, {'.','M'}, 751 {'-',':'}, {'\'','9'},{'"','9'}, {'>','>'}, 752 {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'} 753 #endif 754 }; 755 756 /* 757 --- T.61 characters [0xE0 .. 0xFF] ----------------- 758 */ 759 static Couple trans_t61b_iso8859[48] = { 760 #if (ISO_8859 == 1) 761 {'-','M'}, {0xb9,0}, {0xae,0}, {0xa9,0}, 762 {'T','M'}, {'M','8'}, {0xac,0}, {0xa6,0}, 763 {0,0}, {0,0}, {0,0}, {0,0}, 764 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'}, 765 {'O','m'}, {0xc6,0}, {0xd0,0}, {0xaa,0}, 766 {'H','/'}, {0,0}, {'I','J'}, {'L','.'}, 767 {'L','/'}, {0xd8,0}, {'O','E'}, {0xba,0}, 768 {0xde,0}, {'T','/'}, {'N','G'}, {'\'','n'}, 769 {'k','k'}, {0xe6,0}, {'d','/'}, {0xf0,0}, 770 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'}, 771 {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0}, 772 {0xfe,0}, {'t','/'}, {'n','g'}, {'-','-'} 773 #elif (ISO_8859 == 2) 774 {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'}, 775 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'}, 776 {0,0}, {0,0}, {0,0}, {0,0}, 777 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'}, 778 {'O','m'}, {'A','E'}, {0xd0,0}, {'-','a'}, 779 {'H','/'}, {0,0}, {'I','J'}, {'L','.'}, 780 {0xa3,0}, {'O','/'}, {'O','E'}, {'-','o'}, 781 {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'}, 782 {'k','k'}, {'a','e'}, {0xf0,0}, {'d','-'}, 783 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'}, 784 {0xb3,0}, {'o','/'}, {'o','e'}, {0xdf,0}, 785 {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'} 786 #elif (ISO_8859 == 3) 787 {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'}, 788 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'}, 789 {0,0}, {0,0}, {0,0}, {0,0}, 790 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'}, 791 {'O','m'}, {'A','E'}, {'D','/'}, {'-','a'}, 792 {0xa1,0}, {0,0}, {'I','J'}, {'L','.'}, 793 {'L','/'}, {'O','/'}, {'O','E'}, {'-','o'}, 794 {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'}, 795 {'k','k'}, {'a','e'}, {'d','/'}, {'d','-'}, 796 {0xb1,0}, {0xb9,0}, {'i','j'}, {'l','.'}, 797 {'l','/'}, {'o','/'}, {'o','e'}, {0xdf,0}, 798 {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'} 799 #elif (ISO_8859 == 4) 800 {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'}, 801 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'}, 802 {0,0}, {0,0}, {0,0}, {0,0}, 803 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'}, 804 {'O','m'}, {0xc6,0}, {0xd0,0}, {'-','a'}, 805 {'H','/'}, {0,0}, {'I','J'}, {'L','.'}, 806 {'L','/'}, {0xd8,0}, {'O','E'}, {'-','o'}, 807 {'T','H'}, {0xac,0}, {0xbd,0}, {'\'','n'}, 808 {0xa2,0}, {0xe6,0}, {0xf0,0}, {'d','-'}, 809 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'}, 810 {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0}, 811 {'t','h'}, {0xbc,0}, {0xbf,0}, {'-','-'} 812 #elif (ISO_8859 == 9) 813 {'-','M'}, {0xb9,0}, {0xae,0}, {0xa9,0}, 814 {'T','M'}, {'M','8'}, {0xac,0}, {0xa6,0}, 815 {0,0}, {0,0}, {0,0}, {0,0}, 816 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'}, 817 {'O','m'}, {0xc6,0}, {'D','/'}, {0xaa,0}, 818 {'H','/'}, {0,0}, {'I','J'}, {'L','.'}, 819 {'L','/'}, {0xd8,0}, {'O','E'}, {0xba,0}, 820 {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'}, 821 {'k','k'}, {0xe6,0}, {'d','/'}, {'d','-'}, 822 {'h','/'}, {0xfd,0}, {'i','j'}, {'l','.'}, 823 {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0}, 824 {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'} 825 #elif (ISO_8859 == 10) 826 {0xbd,0}, {'1','S'}, {'R','g'}, {'C','o'}, 827 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'}, 828 {0,0}, {0,0}, {0,0}, {0,0}, 829 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'}, 830 {'O','m'}, {0xc6,0}, {0xa9,0}, {'-','a'}, 831 {'H','/'}, {0,0}, {'I','J'}, {'L','.'}, 832 {'L','/'}, {0xd8,0}, {'O','E'}, {'-','o'}, 833 {0xde,0}, {0xab,0}, {0xaf,0}, {'\'','n'}, 834 {0xff,0}, {0xe6,0}, {0xb9,0}, {0xf0,0}, 835 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'}, 836 {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0}, 837 {0xfe,0}, {0xbb,0}, {0xbf,0}, {'-','-'} 838 #else 839 {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'}, 840 {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'}, 841 {0,0}, {0,0}, {0,0}, {0,0}, 842 {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'}, 843 {'O','m'}, {'A','E'}, {'D','/'}, {'-','a'}, 844 {'H','/'}, {0,0}, {'I','J'}, {'L','.'}, 845 {'L','/'}, {'O','/'}, {'O','E'}, {'-','o'}, 846 {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'}, 847 {'k','k'}, {'a','e'}, {'d','/'}, {'d','-'}, 848 {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'}, 849 {'l','/'}, {'o','/'}, {'o','e'}, {'s','s'}, 850 {'t','h'}, {'t','-'}, {'n','g'}, {'-','-'} 851 #endif 852 }; 853 854 /* 855 --- ISO 8859-n characters <0xA0 .. 0xFF> ------------------- 856 */ 857 #if (ISO_8859 == 1) 858 static Couple trans_iso8859_t61[96] = { 859 {0xa0,0}, {0xa1,0}, {0xa2,0}, {0xa3,0}, 860 {0xa8,0}, {0xa5,0}, {0xd7,0}, {0xa7,0}, 861 {0xc8,ALONE}, {0xd3,0}, {0xe3,0}, {0xab,0}, 862 {0xd6,0}, {0xff,0}, {0xd2,0}, {0xc5,ALONE}, 863 {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0}, 864 {0xc2,ALONE}, {0xb5,0}, {0xb6,0}, {0xb7,0}, 865 {0xcb,ALONE}, {0xd1,0}, {0xeb,0}, {0xbb,0}, 866 {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0}, 867 {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'}, 868 {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xcb,'C'}, 869 {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'}, 870 {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'}, 871 {0xe2,0}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'}, 872 {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0}, 873 {0xe9,0}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'}, 874 {0xc8,'U'}, {0xc2,'Y'}, {0xec,0}, {0xfb,0}, 875 {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'}, 876 {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xcb,'c'}, 877 {0xc1,'e'}, {0xc2,'e'}, {0xc3,'e'}, {0xc8,'e'}, 878 {0xc1,'i'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'}, 879 {0xf3,0}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'}, 880 {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0}, 881 {0xf9,0}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'}, 882 {0xc8,'u'}, {0xc2,'y'}, {0xfc,0}, {0xc8,'y'} 883 }; 884 #elif (ISO_8859 == 2) 885 static Couple trans_iso8859_t61[96] = { 886 {0xa0,0}, {0xce,'A'}, {0xc6,ALONE}, {0xe8,0}, 887 {0xa8,0}, {0xcf,'L'}, {0xc2,'S'}, {0xa7,0}, 888 {0xc8,ALONE}, {0xcf,'S'}, {0xcb,'S'}, {0xcf,'T'}, 889 {0xc2,'Z'}, {0xff,0}, {0xcf,'Z'}, {0xc7,'Z'}, 890 {0xb0,0}, {0xce,'a'}, {0xce,ALONE}, {0xf8,0}, 891 {0xc2,ALONE}, {0xcf,'l'}, {0xc2,'s'}, {0xcf,ALONE}, 892 {0xcb,ALONE}, {0xcf,'s'}, {0xcb,'s'}, {0xcf,'t'}, 893 {0xc2,'z'}, {0xcd,ALONE}, {0xcf,'z'}, {0xc7,'z'}, 894 {0xc2,'R'}, {0xc2,'A'}, {0xc3,'A'}, {0xc6,'A'}, 895 {0xc8,'A'}, {0xc2,'L'}, {0xc2,'C'}, {0xcb,'C'}, 896 {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'}, 897 {0xcf,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xcf,'D'}, 898 {0xe2,0}, {0xc2,'N'}, {0xcf,'N'}, {0xc2,'O'}, 899 {0xc3,'O'}, {0xcd,'O'}, {0xc8,'O'}, {0xb4,0}, 900 {0xcf,'R'}, {0xca,'U'}, {0xc2,'U'}, {0xcd,'U'}, 901 {0xc8,'U'}, {0xc2,'Y'}, {0xcb,'T'}, {0xfb,0}, 902 {0xc2,'r'}, {0xc2,'a'}, {0xc3,'a'}, {0xc6,'a'}, 903 {0xc8,'a'}, {0xc2,'l'}, {0xc2,'c'}, {0xcb,'c'}, 904 {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'}, 905 {0xcf,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xcf,'d'}, 906 {0xf2,0}, {0xc2,'n'}, {0xcf,'n'}, {0xc2,'o'}, 907 {0xc3,'o'}, {0xcd,'o'}, {0xc8,'o'}, {0xb8,0}, 908 {0xcf,'r'}, {0xca,'u'}, {0xc2,'u'}, {0xcd,'u'}, 909 {0xc8,'u'}, {0xc2,'y'}, {0xcb,'t'}, {0xc7,ALONE} 910 }; 911 #elif (ISO_8859 == 3) 912 static Couple trans_iso8859_t61[96] = { 913 {0xa0,0}, {0xe4,0}, {0xc6,ALONE}, {0xa3,0}, 914 {0xa8,0}, {0,0}, {0xc3,'H'}, {0xa7,0}, 915 {0xc8,ALONE}, {0xc7,'I'}, {0xcb,'S'}, {0xc6,'G'}, 916 {0xc3,'J'}, {0xff,0}, {0,0}, {0xc7,'Z'}, 917 {0xb0,0}, {0xf4,0}, {0xb2,0}, {0xb3,0}, 918 {0xc2,ALONE}, {0xb5,0}, {0xc3,'h'}, {0xb7,0}, 919 {0xcb,ALONE}, {0xf5,0}, {0xcb,'s'}, {0xc6,'g'}, 920 {0xc3,'j'}, {0xbd,0}, {0,0}, {0xc7,'z'}, 921 {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0,0}, 922 {0xc8,'A'}, {0xc7,'C'}, {0xc3,'C'}, {0xcb,'C'}, 923 {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'}, 924 {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'}, 925 {0,0}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'}, 926 {0xc3,'O'}, {0xc7,'G'}, {0xc8,'O'}, {0xb4,0}, 927 {0xc3,'G'}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'}, 928 {0xc8,'U'}, {0xc6,'U'}, {0xc3,'S'}, {0xfb,0}, 929 {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0,0}, 930 {0xc8,'a'}, {0xc7,'c'}, {0xc3,'c'}, {0xcb,'c'}, 931 {0xc1,'e'}, {0xc2,'e'}, {0xc3,'e'}, {0xc8,'e'}, 932 {0xc1,'i'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'}, 933 {0,0}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'}, 934 {0xc3,'o'}, {0xc7,'g'}, {0xc8,'o'}, {0xb8,0}, 935 {0xc3,'g'}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'}, 936 {0xc8,'u'}, {0xc6,'u'}, {0xc3,'s'}, {0xc7,ALONE} 937 }; 938 #elif (ISO_8859 == 4) 939 static Couple trans_iso8859_t61[96] = { 940 {0xa0,0}, {0xce,'A'}, {0xf0,0}, {0xcb,'R'}, 941 {0xa8,0}, {0xc4,'I'}, {0xcb,'L'}, {0xa7,0}, 942 {0xc8,ALONE}, {0xcf,'S'}, {0xc5,'E'}, {0xcb,'G'}, 943 {0xed,0}, {0xff,0}, {0xcf,'Z'}, {0xc5,ALONE}, 944 {0xb0,0}, {0xce,'a'}, {0xce,ALONE}, {0xcb,'r'}, 945 {0xc2,ALONE}, {0xc4,'i'}, {0xcb,'l'}, {0xcf,ALONE}, 946 {0xcb,ALONE}, {0xcf,'s'}, {0xc5,'e'}, {0xcb,'g'}, 947 {0xfd,0}, {0xee,0}, {0xcf,'z'}, {0xfe,0}, 948 {0xc5,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'}, 949 {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xce,'I'}, 950 {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'}, 951 {0xc7,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xc5,'I'}, 952 {0xe2,0}, {0xcb,'N'}, {0xc5,'O'}, {0xcb,'K'}, 953 {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0}, 954 {0xe9,0}, {0xce,'U'}, {0xc2,'U'}, {0xc3,'U'}, 955 {0xc8,'U'}, {0xc4,'U'}, {0xc5,'U'}, {0xfb,0}, 956 {0xc5,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'}, 957 {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xce,'i'}, 958 {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'}, 959 {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc5,'i'}, 960 {0xf2,0}, {0xcb,'n'}, {0xc5,'o'}, {0xcb,'k'}, 961 {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0}, 962 {0xf9,0}, {0xce,'u'}, {0xc2,'u'}, {0xc3,'u'}, 963 {0xc8,'u'}, {0xc4,'u'}, {0xc5,'u'}, {0xc7,ALONE} 964 }; 965 #elif (ISO_8859 == 9) 966 static Couple trans_iso8859_t61[96] = { 967 {0xa0,0}, {0xa1,0}, {0xa2,0}, {0xa3,0}, 968 {0xa8,0}, {0xa5,0}, {0xd7,0}, {0xa7,0}, 969 {0xc8,ALONE}, {0xd3,0}, {0xe3,0}, {0xab,0}, 970 {0xd6,0}, {0xff,0}, {0xd2,0}, {0xc5,ALONE}, 971 {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0}, 972 {0xc2,ALONE}, {0xb5,0}, {0xb6,0}, {0xb7,0}, 973 {0xcb,ALONE}, {0xd1,0}, {0xeb,0}, {0xbb,0}, 974 {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0}, 975 {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'}, 976 {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xcb,'C'}, 977 {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'}, 978 {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'}, 979 {0xc6,'G'}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'}, 980 {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0}, 981 {0xe9,0}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'}, 982 {0xc8,'U'}, {0xc7,'I'}, {0xcb,'S'}, {0xfb,0}, 983 {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'}, 984 {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xcb,'c'}, 985 {0xc1,'e'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'}, 986 {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc5,'i'}, 987 {0xc6,'g'}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'}, 988 {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0}, 989 {0xf9,0}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'}, 990 {0xc8,'u'}, {0xf5,0}, {0xcb,'s'}, {0xc8,'y'} 991 }; 992 #elif (ISO_8859 == 10) 993 static Couple trans_iso8859_t61[96] = { 994 {0xa0,0}, {0xce,'A'}, {0xc5,'E'}, {0xcb,'G'}, 995 {0xc5,'I'}, {0xc4,'I'}, {0xcb,'K'}, {0xa7,0}, 996 {0xcb,'L'}, {0xe2,0}, {0xcf,'S'}, {0xed,0}, 997 {0xcf,'Z'}, {0xff,0}, {0xc5,'U'}, {0xee,0}, 998 {0xb0,0}, {0xce,'a'}, {0xc5,'e'}, {0xcb,'g'}, 999 {0xc5,'i'}, {0xc4,'i'}, {0xcb,'k'}, {0xb7,0}, 1000 {0xcb,'l'}, {0xf2,0}, {0xcf,'s'}, {0xfd,0}, 1001 {0xcf,'z'}, {0xd0,0}, {0xc5,'u'}, {0xfe,0}, 1002 {0xc5,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'}, 1003 {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xce,'I'}, 1004 {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'}, 1005 {0xc7,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'}, 1006 {0,0}, {0xcb,'N'}, {0xc5,'O'}, {0xc2,'O'}, 1007 {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xc4,'U'}, 1008 {0xe9,0}, {0xce,'U'}, {0xc2,'U'}, {0xc3,'U'}, 1009 {0xc8,'U'}, {0xc2,'Y'}, {0xec,0}, {0xfb,0}, 1010 {0xc5,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'}, 1011 {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xce,'i'}, 1012 {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'}, 1013 {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'}, 1014 {0xf3,0}, {0xcb,'n'}, {0xc5,'o'}, {0xc2,'o'}, 1015 {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xc4,'u'}, 1016 {0xf9,0}, {0xce,'u'}, {0xc2,'u'}, {0xc3,'u'}, 1017 {0xc8,'u'}, {0xc2,'y'}, {0xfc,0}, {0xf0,0} 1018 }; 1019 #endif 1020 1021 1022 static Byte * 1023 c_to_hh( Byte *o, Byte c ) 1024 { 1025 Byte n; 1026 1027 *o++ = '{'; *o++ = 'x'; 1028 n = c >> 4; 1029 *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n; 1030 n = c & 0x0F; 1031 *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n; 1032 *o++ = '}'; 1033 return o; 1034 } 1035 1036 1037 static Byte * 1038 c_to_cc( Byte *o, Couple *cc, Byte c ) 1039 { 1040 if ( (*cc).a != 0 ) { 1041 if ( (*cc).b == 0 ) 1042 *o++ = (*cc).a; 1043 else { 1044 *o++ = '{'; 1045 *o++ = (*cc).a; 1046 *o++ = (*cc).b; 1047 *o++ = '}'; 1048 } 1049 return o; 1050 } 1051 else 1052 return c_to_hh( o, c ); 1053 } 1054 1055 /* --- routine to convert from T.61 to ISO 8859-n --- */ 1056 1057 int 1058 ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input ) 1059 { 1060 Byte *s, *oo, *o; 1061 unsigned int n; 1062 int c; 1063 unsigned long len; 1064 Couple *cc; 1065 1066 LDAPDebug( LDAP_DEBUG_TRACE, "ldap_t61_to_8859 input length: %ld\n", 1067 *buflenp, 0, 0 ); 1068 1069 len = *buflenp; 1070 s = (Byte *) *bufp; 1071 1072 if ( (o = oo = (Byte *)NSLDAPI_MALLOC( 2 * len + 64 )) == NULL ) { 1073 return( 1 ); 1074 } 1075 1076 while ( (char *)s - *(char **)bufp < len ) { 1077 switch ( *s >> 4 ) { 1078 1079 case 0xA: case 0xB: 1080 o = c_to_cc( o, &trans_t61a_iso8859[ *s - 0xA0 ], *s ); 1081 s++; 1082 break; 1083 1084 case 0xD: case 0xE: case 0xF: 1085 o = c_to_cc( o, &trans_t61b_iso8859[ *s - 0xD0 ], *s ); 1086 s++; 1087 break; 1088 1089 case 0xC: 1090 if ( (*s == 0xC0) || (*s == 0xC9) || (*s == 0xCC) ) { 1091 o = c_to_hh( o, *s++ ); 1092 break; 1093 } 1094 1095 n = (*s++) - 0xC0; 1096 switch ( *s ) { 1097 1098 case 'A': c = letter_w_diacritic[n][0]; break; 1099 case 'C': c = letter_w_diacritic[n][1]; break; 1100 case 'D': c = letter_w_diacritic[n][2]; break; 1101 case 'E': c = letter_w_diacritic[n][3]; break; 1102 case 'G': c = letter_w_diacritic[n][4]; break; 1103 case 'H': c = letter_w_diacritic[n][5]; break; 1104 case 'I': c = letter_w_diacritic[n][6]; break; 1105 case 'J': c = letter_w_diacritic[n][7]; break; 1106 case 'K': c = letter_w_diacritic[n][8]; break; 1107 case 'L': c = letter_w_diacritic[n][9]; break; 1108 case 'N': c = letter_w_diacritic[n][10]; break; 1109 case 'O': c = letter_w_diacritic[n][11]; break; 1110 case 'R': c = letter_w_diacritic[n][12]; break; 1111 case 'S': c = letter_w_diacritic[n][13]; break; 1112 case 'T': c = letter_w_diacritic[n][14]; break; 1113 case 'U': c = letter_w_diacritic[n][15]; break; 1114 case 'W': c = letter_w_diacritic[n][16]; break; 1115 case 'Y': c = letter_w_diacritic[n][17]; break; 1116 case 'Z': c = letter_w_diacritic[n][18]; break; 1117 1118 case 'a': c = letter_w_diacritic[n][19]; break; 1119 case 'c': c = letter_w_diacritic[n][20]; break; 1120 case 'd': c = letter_w_diacritic[n][21]; break; 1121 case 'e': c = letter_w_diacritic[n][22]; break; 1122 case 'g': c = letter_w_diacritic[n][23]; break; 1123 case 'h': c = letter_w_diacritic[n][24]; break; 1124 case 'i': c = letter_w_diacritic[n][25]; break; 1125 case 'j': c = letter_w_diacritic[n][26]; break; 1126 case 'k': c = letter_w_diacritic[n][27]; break; 1127 case 'l': c = letter_w_diacritic[n][28]; break; 1128 case 'n': c = letter_w_diacritic[n][29]; break; 1129 case 'o': c = letter_w_diacritic[n][30]; break; 1130 case 'r': c = letter_w_diacritic[n][31]; break; 1131 case 's': c = letter_w_diacritic[n][32]; break; 1132 case 't': c = letter_w_diacritic[n][33]; break; 1133 case 'u': c = letter_w_diacritic[n][34]; break; 1134 case 'w': c = letter_w_diacritic[n][35]; break; 1135 case 'y': c = letter_w_diacritic[n][36]; break; 1136 case 'z': c = letter_w_diacritic[n][37]; break; 1137 1138 case ALONE: c = (( !diacritic[n].b ) ? diacritic[n].a : -1); 1139 break; 1140 1141 default: c = 0; 1142 } 1143 1144 if ( c > 0 ) { 1145 *o++ = c; s++; 1146 } else { 1147 *o++ = '{'; 1148 if ( c == -1 ) { 1149 *o++ = ( ( *s == ALONE ) ? ' ' : *s ); 1150 s++; 1151 } else { 1152 *o++ = '"'; 1153 } 1154 *o++ = diacritic[n].a; 1155 *o++ = '}'; 1156 } 1157 break; 1158 1159 #if (ISO_8859 == 0) 1160 case 0x8: case 0x9: 1161 *o++ = 0x1B; /* <ESC> */ 1162 *o++ = *s++ - 0x40; 1163 break; 1164 #endif 1165 1166 default: 1167 *o++ = *s++; 1168 } 1169 } 1170 1171 len = o - oo; 1172 o = oo; 1173 1174 if ( (oo = (Byte *)NSLDAPI_REALLOC( o, len )) == NULL ) { 1175 NSLDAPI_FREE( o ); 1176 return( 1 ); 1177 } 1178 1179 if ( free_input ) { 1180 NSLDAPI_FREE( *bufp ); 1181 } 1182 *bufp = (char *) oo; 1183 *buflenp = len; 1184 return( 0 ); 1185 } 1186 1187 1188 static int 1189 hh_to_c( Byte *h ) 1190 { 1191 Byte c; 1192 1193 if ( (*h >= '0') && (*h <= '9') ) c = *h++ - '0'; 1194 else if ( (*h >= 'A') && (*h <= 'F') ) c = *h++ - 'A' + 10; 1195 else if ( (*h >= 'a') && (*h <= 'f') ) c = *h++ - 'a' + 10; 1196 else return -1; 1197 1198 c <<= 4; 1199 1200 if ( (*h >= '0') && (*h <= '9') ) c |= *h - '0'; 1201 else if ( (*h >= 'A') && (*h <= 'F') ) c |= *h - 'A' + 10; 1202 else if ( (*h >= 'a') && (*h <= 'f') ) c |= *h - 'a' + 10; 1203 else return -1; 1204 1205 return c; 1206 } 1207 1208 1209 static Byte * 1210 cc_to_t61( Byte *o, Byte *s ) 1211 { 1212 int n, c = 0; 1213 1214 switch ( *(s + 1) ) { 1215 1216 case '`': c = -1; break; /* <grave-accent> */ 1217 1218 case '!': 1219 switch ( *s ) { 1220 case '!': c = 0x7C; break; /* <vertical-line> */ 1221 case '(': c = 0x7B; break; /* <left-curly-bracket> */ 1222 case '-': c = 0xAD; break; /* <upwards-arrow> */ 1223 default: c = -1; /* <grave-accent> */ 1224 } 1225 break; 1226 1227 #if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \ 1228 (ISO_8859 == 4) || (ISO_8859 == 9) 1229 case 0xB4: 1230 #endif 1231 case '\'': c = -2; break; /* <acute-accent> */ 1232 1233 case '^': c = -3; break; /* <circumflex-acent> */ 1234 1235 case '>': 1236 switch ( *s ) { 1237 case ')': c = 0x5D; break; /* <right-square-bracket> */ 1238 case '>': c = 0xBB; break; /* <right-angle-quotation> */ 1239 case '-': c = 0xAE; break; /* <rightwards-arrow> */ 1240 default: c = -3; /* <circumflex-acent> */ 1241 } 1242 break; 1243 1244 case '~': 1245 case '?': c = -4; break; /* <tilde> */ 1246 1247 #if (ISO_8859 == 1) || (ISO_8859 == 4) || (ISO_8859 == 9) 1248 case 0xAF: c = -5; break; /* <macron> */ 1249 #endif 1250 1251 case '-': 1252 switch ( *s ) { 1253 case '-': c = 0xFF; break; /* <soft-hyphen> */ 1254 case '<': c = 0xAC; break; /* <leftwards arrow> */ 1255 case '+': c = 0xB1; break; /* <plus-minus> */ 1256 case 'd': c = 0xF3; break; /* <eth> */ 1257 default: c = -5; /* <macron> */ 1258 } 1259 break; 1260 1261 #if (ISO_8859 == 2) || (ISO_8859 == 3) 1262 case 0xA2: c = -6; break; /* <breve> */ 1263 #endif 1264 1265 case '(': 1266 if ( *s == '<' ) c = 0x5B; /* <left-square-bracket> */ 1267 else c = -6; /* <breve> */ 1268 break; 1269 1270 #if (ISO_8859 == 2) || (ISO_8859 == 3) || (ISO_8859 == 4) 1271 case 0xFF: c = -7; break; /* <dot-accent> */ 1272 #endif 1273 1274 case '.': 1275 switch ( *s ) { 1276 case 'i': c = 0xF5; break; /* <dotless-i> */ 1277 case 'L': c = 0xE7; break; /* <L-middle-dot> */ 1278 case 'l': c = 0xF7; break; /* <l-middle-dot> */ 1279 default: c = -7; /* <dot-accent> */ 1280 } 1281 break; 1282 1283 #if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \ 1284 (ISO_8859 == 4) || (ISO_8859 == 9) 1285 case 0xA8: c = -8; break; /* <diaeresis> */ 1286 #endif 1287 1288 case ':': 1289 if ( *s == '-') c = 0xB8; /* <division-sign> */ 1290 else c = -8; /* <diaeresis> */ 1291 break; 1292 1293 #if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \ 1294 (ISO_8859 == 4) || (ISO_8859 == 9) || (ISO_8859 == 10) 1295 case 0xB0: 1296 #endif 1297 case '0': c = -10; break; /* <ring-above> */ 1298 1299 #if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \ 1300 (ISO_8859 == 4) || (ISO_8859 == 9) 1301 case 0xB8: 1302 #endif 1303 case ',': c = -11; break; /* <cedilla> */ 1304 1305 #if (ISO_8859 == 2) 1306 case 0xBD: 1307 #endif 1308 case '"': c = -13; break; /* <double-acute-accent> */ 1309 1310 #if (ISO_8859 == 2) || (ISO_8859 == 4) 1311 case 0xB2: 1312 #endif 1313 case ';': c = -14; break; /* <ogonek> */ 1314 1315 #if (ISO_8859 == 2) || (ISO_8859 == 4) 1316 case 0xB7: c = -15; break; /* <caron> */ 1317 #endif 1318 1319 case ')': 1320 if ( *s == '!' ) c = 0x7D; /* <left-curly-bracket> */ 1321 break; 1322 1323 case '<': 1324 if ( *s == '<' ) c = 0xAB; /* <left-angle-quotation> */ 1325 else c = -15; /* <caron> */ 1326 break; 1327 1328 case '/': 1329 switch ( *s ) { 1330 case '/': c = 0x5C; break; /* <reverse-solidus> */ 1331 case 'D': c = 0xE2; break; /* <D-stroke> */ 1332 case 'd': c = 0xF2; break; /* <d-stroke> */ 1333 case 'H': c = 0xE4; break; /* <H-stroke> */ 1334 case 'h': c = 0xF4; break; /* <h-stroke> */ 1335 case 'L': c = 0xE8; break; /* <L-stroke> */ 1336 case 'l': c = 0xF8; break; /* <l-stroke> */ 1337 case 'O': c = 0xE9; break; /* <O-stroke> */ 1338 case 'o': c = 0xF9; break; /* <o-stroke> */ 1339 case 'T': c = 0xED; break; /* <T-stroke> */ 1340 case 't': c = 0xFD; break; /* <t-stroke> */ 1341 } 1342 break; 1343 1344 case '2': 1345 if ( *s == '1' ) c = 0xBD; /* <one-half> */ 1346 break; 1347 1348 case '4': 1349 switch ( *s ) { 1350 case '1': c = 0xBC; break; /* <one-quarter> */ 1351 case '3': c = 0xBE; break; /* <three-quarters> */ 1352 } 1353 break; 1354 1355 case '6': 1356 switch ( *s ) { 1357 case '\'': c = 0xA9; break; /* <left-single-quotation> */ 1358 case '"': c = 0xAA; break; /* <left-double-quotation> */ 1359 } 1360 break; 1361 1362 case '8': 1363 switch ( *s ) { 1364 case '1': c = 0xDC; break; /* <one-eighth> */ 1365 case '3': c = 0xDD; break; /* <three-eighths> */ 1366 case '5': c = 0xDE; break; /* <five-eighths> */ 1367 case '7': c = 0xDF; break; /* <seven-eighths> */ 1368 case 'M': c = 0xD5; break; /* <eighth-note> */ 1369 } 1370 break; 1371 1372 case '9': 1373 switch ( *s ) { 1374 case '\'': c = 0xB9; break; /* <right-single-quotation> */ 1375 case '"': c = 0xBA; break; /* <right-double-quotation> */ 1376 } 1377 break; 1378 1379 case 'A': 1380 if ( *s == 'A' ) c = -10; /* <ring-above> + <A> */ 1381 break; 1382 1383 case 'a': 1384 switch ( *s ) { 1385 case '-': c = 0xE3; break; /* <femenine-ordinal-a> */ 1386 case 'a': c = -10; break; /* <ring-above> + <a> */ 1387 } 1388 break; 1389 1390 case 'B': 1391 if ( *s == 'B' ) c = 0xD7; /* <broken-bar> */ 1392 break; 1393 1394 case 'b': 1395 if ( *s == 'N' ) c = 0xA6; /* <number-sign> */ 1396 break; 1397 1398 case 'd': 1399 if ( *s == 'P' ) c = 0xA3; /* <pound-sign> */ 1400 break; 1401 1402 case 'E': 1403 switch ( *s ) { 1404 case 'S': c = 0xA7; break; /* <section-sign> */ 1405 case 'A': c = 0xE1; break; /* <AE> */ 1406 case 'O': c = 0xEA; break; /* <OE> */ 1407 } 1408 break; 1409 1410 case 'e': 1411 switch ( *s ) { 1412 case 'a': c = 0xF1; break; /* <ae> */ 1413 case 'o': c = 0xFA; break; /* <oe> */ 1414 case 'Y': c = 0xA5; break; /* <yen-sign> */ 1415 } 1416 break; 1417 1418 case 'G': 1419 switch ( *s ) { 1420 case 'D': c = 0xB0; break; /* <degree-sign> */ 1421 case 'N': c = 0xEE; break; /* <Eng> */ 1422 } 1423 break; 1424 1425 case 'g': 1426 switch ( *s ) { 1427 case 'R': c = 0xD2; break; /* <registered-sign> */ 1428 case 'n': c = 0xFE; break; /* <eng> */ 1429 } 1430 break; 1431 1432 case 'H': 1433 if ( *s == 'T' ) c = 0xEC; /* <Thorn> */ 1434 break; 1435 1436 case 'h': 1437 if ( *s == 't' ) c = 0xFC; /* <thorn> */ 1438 break; 1439 1440 case 'I': 1441 switch ( *s ) { 1442 case 'P': c = 0xB6; break; /* <pilcrow-sign> */ 1443 case '!': c = 0xA1; break; /* <inverted-exclamation> */ 1444 case '?': c = 0xBF; break; /* <inverted-question> */ 1445 } 1446 break; 1447 1448 case 'J': 1449 if ( *s == 'I' ) c = 0xE6; /* <IJ> */ 1450 break; 1451 1452 case 'j': 1453 if ( *s == 'i' ) c = 0xF6; /* <ij> */ 1454 break; 1455 1456 case 'k': 1457 if ( *s == 'k' ) c = 0xF0; /* <kra> */ 1458 break; 1459 1460 case 'M': 1461 switch ( *s ) { 1462 case '.': c = 0xB7; break; /* <middle-dot> */ 1463 case '-': c = 0xD0; break; /* <em-dash> */ 1464 case 'T': c = 0xD4; break; /* <trade-mark-sign> */ 1465 } 1466 break; 1467 1468 case 'm': 1469 switch ( *s ) { 1470 case '\'': /* <macron> RFC 1345 */ 1471 case ' ': c = -5; break; /* <macron> */ 1472 case 'O': c = 0xE0; break; /* <Ohm sign> */ 1473 } 1474 break; 1475 1476 case 'n': 1477 if ( *s == '\'' ) c = 0xEF; /* <n-preceded-by-apostrophe> */ 1478 break; 1479 1480 case 'O': 1481 switch ( *s ) { 1482 case 'D': c = 0xA4; break; /* <dollar-sign> */ 1483 case 'N': c = 0xD6; break; /* <not-sign> */ 1484 } 1485 break; 1486 1487 case 'o': 1488 switch ( *s ) { 1489 case 'C': c = 0xD3; break; /* <copyright-sign> */ 1490 case '-': c = 0xEB; break; /* <masculine-ordinal-o> */ 1491 } 1492 break; 1493 1494 case 'S': 1495 switch ( *s ) { 1496 case '1': c = 0xD1; break; /* <superscript-1> */ 1497 case '2': c = 0xB2; break; /* <superscript-2> */ 1498 case '3': c = 0xB3; break; /* <superscript-3> */ 1499 case 'N': c = 0xA0; break; /* <no-break-space> */ 1500 } 1501 break; 1502 1503 case 's': 1504 if ( *s == 's' ) c = 0xFB; /* <sharp-s> */ 1505 break; 1506 1507 case 't': 1508 if ( *s == 'C' ) c = 0xA2; /* <cent-sign> */ 1509 break; 1510 1511 case 'u': 1512 if ( *s == 'C' ) c = 0xA8; /* <currency-sign> */ 1513 break; 1514 1515 case 'v': 1516 if ( *s == '-' ) c = 0xAF; /* <downwards-arrow> */ 1517 break; 1518 1519 case 'X': 1520 if ( *s == '*' ) c = 0xB4; /* <multiplication-sign> */ 1521 break; 1522 1523 case 'y': 1524 if ( *s == 'M' ) c = 0xB5; /* <micro-sign> */ 1525 break; 1526 } 1527 1528 if ( c > 0 ) { 1529 *o++ = c; 1530 return o; 1531 } else if ( !c ) 1532 return NULL; 1533 1534 /* else: c < 0 */ 1535 n = -c; 1536 switch ( *s ) { 1537 1538 case 'A': c = letter_w_diacritic[n][0]; break; 1539 case 'C': c = letter_w_diacritic[n][1]; break; 1540 case 'D': c = letter_w_diacritic[n][2]; break; 1541 case 'E': c = letter_w_diacritic[n][3]; break; 1542 case 'G': c = letter_w_diacritic[n][4]; break; 1543 case 'H': c = letter_w_diacritic[n][5]; break; 1544 case 'I': c = letter_w_diacritic[n][6]; break; 1545 case 'J': c = letter_w_diacritic[n][7]; break; 1546 case 'K': c = letter_w_diacritic[n][8]; break; 1547 case 'L': c = letter_w_diacritic[n][9]; break; 1548 case 'N': c = letter_w_diacritic[n][10]; break; 1549 case 'O': c = letter_w_diacritic[n][11]; break; 1550 case 'R': c = letter_w_diacritic[n][12]; break; 1551 case 'S': c = letter_w_diacritic[n][13]; break; 1552 case 'T': c = letter_w_diacritic[n][14]; break; 1553 case 'U': c = letter_w_diacritic[n][15]; break; 1554 case 'W': c = letter_w_diacritic[n][16]; break; 1555 case 'Y': c = letter_w_diacritic[n][17]; break; 1556 case 'Z': c = letter_w_diacritic[n][18]; break; 1557 1558 case 'a': c = letter_w_diacritic[n][19]; break; 1559 case 'c': c = letter_w_diacritic[n][20]; break; 1560 case 'd': c = letter_w_diacritic[n][21]; break; 1561 case 'e': c = letter_w_diacritic[n][22]; break; 1562 case 'g': c = letter_w_diacritic[n][23]; break; 1563 case 'h': c = letter_w_diacritic[n][24]; break; 1564 case 'i': c = letter_w_diacritic[n][25]; break; 1565 case 'j': c = letter_w_diacritic[n][26]; break; 1566 case 'k': c = letter_w_diacritic[n][27]; break; 1567 case 'l': c = letter_w_diacritic[n][28]; break; 1568 case 'n': c = letter_w_diacritic[n][29]; break; 1569 case 'o': c = letter_w_diacritic[n][30]; break; 1570 case 'r': c = letter_w_diacritic[n][31]; break; 1571 case 's': c = letter_w_diacritic[n][32]; break; 1572 case 't': c = letter_w_diacritic[n][33]; break; 1573 case 'u': c = letter_w_diacritic[n][34]; break; 1574 case 'w': c = letter_w_diacritic[n][35]; break; 1575 case 'y': c = letter_w_diacritic[n][36]; break; 1576 case 'z': c = letter_w_diacritic[n][37]; break; 1577 1578 case '\'': 1579 case ' ': c = -1; break; 1580 1581 default: c = 0; 1582 } 1583 1584 if ( !c ) 1585 return NULL; 1586 1587 *o++ = n + 0xC0; 1588 *o++ = ( ( (*s == ' ') || (*s == '\'') ) ? ALONE : *s ); 1589 return o; 1590 } 1591 1592 1593 /* --- routine to convert from ISO 8859-n to T.61 --- */ 1594 1595 int 1596 ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input ) 1597 { 1598 Byte *s, *oo, *o, *aux; 1599 int c; 1600 unsigned long len; 1601 Couple *cc; 1602 1603 LDAPDebug( LDAP_DEBUG_TRACE, "ldap_8859_to_t61 input length: %ld\n", 1604 *buflenp, 0, 0 ); 1605 1606 len = *buflenp; 1607 s = (Byte *) *bufp; 1608 1609 if ( (o = oo = (Byte *)NSLDAPI_MALLOC( 2 * len + 64 )) == NULL ) { 1610 return( 1 ); 1611 } 1612 1613 while ( (char *)s - *(char **)bufp < len ) { 1614 switch( *s >> 5 ) { 1615 1616 case 2: 1617 switch ( *s ) { 1618 1619 case '^': *o++ = 0xC3; *o++ = ALONE; s++; break; 1620 1621 case '\\': 1622 s++; 1623 if ( (c = hh_to_c( s )) != -1 ) { 1624 *o++ = c; 1625 s += 2; 1626 } else 1627 *o++ = '\\'; 1628 break; 1629 1630 default: *o++ = *s++; 1631 } 1632 break; 1633 1634 case 3: 1635 switch ( *s ) { 1636 1637 case '`': *o++ = 0xC1; *o++ = ALONE; s++; break; 1638 case '~': *o++ = 0xC4; *o++ = ALONE; s++; break; 1639 1640 case '{': 1641 s++; 1642 if ( *(s + 2) == '}' ) { 1643 if ( (aux = cc_to_t61( o, s )) != NULL ) { 1644 o = aux; 1645 s += 3; 1646 } else { 1647 *o++ = '{'; 1648 } 1649 } else if ( (*(s + 3) == '}') && ( (*s == 'x') || (*s == 'X') ) && 1650 ( (c = hh_to_c( s + 1 )) != -1 ) ) { 1651 *o++ = c; 1652 s += 4; 1653 } else { 1654 *o++ = '{'; 1655 } 1656 break; 1657 1658 default: 1659 *o++ = *s++; 1660 } 1661 break; 1662 1663 #if (ISO_8859 == 0) 1664 case 4: case 5: case 6: case 7: 1665 s++; 1666 break; 1667 #else 1668 case 5: case 6: case 7: 1669 # if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \ 1670 (ISO_8859 == 4) || (ISO_8859 == 9) || (ISO_8859 == 10) 1671 if ( (*(cc = &trans_iso8859_t61[ *s - 0xA0 ])).a ) { 1672 *o++ = (*cc).a; 1673 if ( (*cc).b ) *o++ = (*cc).b; 1674 } 1675 # endif 1676 s++; 1677 break; 1678 #endif 1679 1680 default: 1681 *o++ = *s++; 1682 } 1683 } 1684 1685 len = o - oo; 1686 o = oo; 1687 1688 if ( (oo = (Byte *)NSLDAPI_REALLOC( o, len )) == NULL ) { 1689 NSLDAPI_FREE( o ); 1690 return( 1 ); 1691 } 1692 1693 if ( free_input ) { 1694 NSLDAPI_FREE( *bufp ); 1695 } 1696 *bufp = (char *) oo; 1697 *buflenp = len; 1698 return( 0 ); 1699 } 1700 1701 1702 #ifdef NOT_NEEDED_IN_LIBLDAP /* mcs@umich.edu 12 Oct 1995 */ 1703 /* --- routine to convert "escaped" (\hh) characters to 8bits --- */ 1704 1705 void convert_escaped_to_8bit( s ) 1706 char *s; 1707 { 1708 char *o = s; 1709 int c; 1710 1711 while ( *s ) { 1712 if ( *s == '\\' ) { 1713 if ( (c = hh_to_c( ++s )) != -1 ) { 1714 *o++ = c; 1715 s += 2; 1716 } else 1717 *o++ = '\\'; 1718 } else 1719 *o++ = *s++; 1720 } 1721 *o = '\0'; 1722 } 1723 1724 /* --- routine to convert 8bits characters to the "escaped" (\hh) form --- */ 1725 1726 char *convert_8bit_to_escaped( s ) 1727 Byte *s; 1728 { 1729 Byte *o, *oo; 1730 Byte n; 1731 1732 if ( (o = oo = (Byte *)NSLDAPI_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) { 1733 return( NULL ); 1734 } 1735 1736 while ( *s ) { 1737 if ( *s < 0x80 ) 1738 *o++ = *s++; 1739 else { 1740 *o++ = '\\'; 1741 n = *s >> 4; 1742 *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n; 1743 n = *s++ & 0x0F; 1744 *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n; 1745 } 1746 } 1747 *o = '\0'; 1748 1749 o = oo; 1750 1751 if ( (oo = (Byte *)NSLDAPI_REALLOC( o, strlen( o ) + 1 )) == NULL ) { 1752 NSLDAPI_FREE( o ); 1753 return( NULL ); 1754 } 1755 1756 return( (char *)oo ); 1757 } 1758 1759 /* --- routine to convert from T.61 to printable characters --- */ 1760 1761 /* 1762 printable characters [RFC 1488]: 'A'..'Z', 'a'..'z', '0'..'9', 1763 '\'', '(', ')', '+', ',', '-', '.', '/', ':', '?, ' '. 1764 1765 that conversion is language dependent. 1766 */ 1767 1768 static Couple last_t61_printabled[32] = { 1769 {0,0}, {'A','E'}, {'D',0}, {0,0}, 1770 {'H',0}, {0,0}, {'I','J'}, {'L',0}, 1771 {'L',0}, {'O',0}, {'O','E'}, {0,0}, 1772 {'T','H'}, {'T',0}, {'N','G'}, {'n',0}, 1773 {'k',0}, {'a','e'}, {'d',0}, {'d',0}, 1774 {'h',0}, {'i',0}, {'i','j'}, {'l',0}, 1775 {'l',0}, {'o',0}, {'o','e'}, {'s','s'}, 1776 {'t','h'}, {'t',0}, {'n','g'}, {0,0} 1777 }; 1778 1779 char *t61_printable( s ) 1780 Byte *s; 1781 { 1782 Byte *o, *oo; 1783 Byte n; 1784 Couple *cc; 1785 1786 if ( (o = oo = (Byte *)NSLDAPI_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) { 1787 return( NULL ); 1788 } 1789 1790 while ( *s ) { 1791 if ( ( (*s >= 'A') && (*s <= 'Z') ) || 1792 ( (*s >= 'a') && (*s <= 'z') ) || 1793 ( (*s >= '0') && (*s <= '9') ) || 1794 ( (*s >= '\'') && (*s <= ')') ) || 1795 ( (*s >= '+') && (*s <= '/') ) || 1796 ( *s == '?' ) || ( *s == ' ' ) ) 1797 *o++ = *s++; 1798 else { 1799 if ( *s >= 0xE0 ) { 1800 if ( (*(cc = &last_t61_printabled[ *s - 0xE0 ])).a ) { 1801 *o++ = (*cc).a; 1802 if ( (*cc).b ) *o++ = (*cc).b; 1803 } 1804 } 1805 else if ( (*s >> 4) == 0xC ) { 1806 switch ( *s ) { 1807 case 0xCA: /* ring */ 1808 switch ( *(s + 1) ) { 1809 case 'A': *o++ = 'A'; *o++ = 'A'; s++; break; /* Swedish */ 1810 case 'a': *o++ = 'a'; *o++ = 'a'; s++; break; /* Swedish */ 1811 } 1812 break; 1813 1814 case 0xC8: /* diaeresis */ 1815 switch ( *(s + 1) ) { 1816 case 'Y': *o++ = 'I'; *o++ = 'J'; s++; break; /* Dutch */ 1817 case 'y': *o++ = 'i'; *o++ = 'j'; s++; break; /* Dutch */ 1818 } 1819 break; 1820 } 1821 } 1822 s++; 1823 } 1824 } 1825 *o = '\0'; 1826 1827 o = oo; 1828 1829 if ( (oo = (Byte *)NSLDAPI_REALLOC( o, strlen( o ) + 1 )) == NULL ) { 1830 NSLDAPI_FREE( o ); 1831 return( NULL ); 1832 } 1833 1834 return( (char *)oo ); 1835 } 1836 #endif /* NOT_NEEDED_IN_LIBLDAP */ /* mcs@umich.edu 12 Oct 1995 */ 1837 1838 #endif /* LDAP_CHARSET_8859 */ 1839 #endif /* STR_TRANSLATION */ 1840