ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

encoding.c
Go to the documentation of this file.
00001 /*
00002  * encoding.c : implements the encoding conversion functions needed for XML
00003  *
00004  * Related specs:
00005  * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies
00006  * rfc2781        UTF-16, an encoding of ISO 10646, P. Hoffman, F. Yergeau
00007  * [ISO-10646]    UTF-8 and UTF-16 in Annexes
00008  * [ISO-8859-1]   ISO Latin-1 characters codes.
00009  * [UNICODE]      The Unicode Consortium, "The Unicode Standard --
00010  *                Worldwide Character Encoding -- Version 1.0", Addison-
00011  *                Wesley, Volume 1, 1991, Volume 2, 1992.  UTF-8 is
00012  *                described in Unicode Technical Report #4.
00013  * [US-ASCII]     Coded Character Set--7-bit American Standard Code for
00014  *                Information Interchange, ANSI X3.4-1986.
00015  *
00016  * See Copyright for the status of this software.
00017  *
00018  * daniel@veillard.com
00019  *
00020  * Original code for IsoLatin1 and UTF-16 by "Martin J. Duerst" <duerst@w3.org>
00021  */
00022 
00023 #define IN_LIBXML
00024 #include "libxml.h"
00025 
00026 #include <string.h>
00027 
00028 #ifdef HAVE_CTYPE_H
00029 #include <ctype.h>
00030 #endif
00031 #ifdef HAVE_STDLIB_H
00032 #include <stdlib.h>
00033 #endif
00034 #ifdef LIBXML_ICONV_ENABLED
00035 #ifdef HAVE_ERRNO_H
00036 #include <errno.h>
00037 #endif
00038 #endif
00039 #include <libxml/encoding.h>
00040 #include <libxml/xmlmemory.h>
00041 #ifdef LIBXML_HTML_ENABLED
00042 #include <libxml/HTMLparser.h>
00043 #endif
00044 #include <libxml/globals.h>
00045 #include <libxml/xmlerror.h>
00046 
00047 static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
00048 static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
00049 
00050 typedef struct _xmlCharEncodingAlias xmlCharEncodingAlias;
00051 typedef xmlCharEncodingAlias *xmlCharEncodingAliasPtr;
00052 struct _xmlCharEncodingAlias {
00053     const char *name;
00054     const char *alias;
00055 };
00056 
00057 static xmlCharEncodingAliasPtr xmlCharEncodingAliases = NULL;
00058 static int xmlCharEncodingAliasesNb = 0;
00059 static int xmlCharEncodingAliasesMax = 0;
00060 
00061 #if defined(LIBXML_ICONV_ENABLED) || defined(LIBXML_ICU_ENABLED)
00062 #if 0
00063 #define DEBUG_ENCODING  /* Define this to get encoding traces */
00064 #endif
00065 #else
00066 #ifdef LIBXML_ISO8859X_ENABLED
00067 static void xmlRegisterCharEncodingHandlersISO8859x (void);
00068 #endif
00069 #endif
00070 
00071 static int xmlLittleEndian = 1;
00072 
00079 static void
00080 xmlEncodingErrMemory(const char *extra)
00081 {
00082     __xmlSimpleError(XML_FROM_I18N, XML_ERR_NO_MEMORY, NULL, NULL, extra);
00083 }
00084 
00092 static void
00093 xmlEncodingErr(xmlParserErrors error, const char *msg, const char *val)
00094 {
00095     __xmlRaiseError(NULL, NULL, NULL, NULL, NULL,
00096                     XML_FROM_I18N, error, XML_ERR_FATAL,
00097                     NULL, 0, val, NULL, NULL, 0, 0, msg, val);
00098 }
00099 
00100 #ifdef LIBXML_ICU_ENABLED
00101 static uconv_t*
00102 openIcuConverter(const char* name, int toUnicode)
00103 {
00104   UErrorCode status = U_ZERO_ERROR;
00105   uconv_t *conv = (uconv_t *) xmlMalloc(sizeof(uconv_t));
00106   if (conv == NULL)
00107     return NULL;
00108 
00109   conv->uconv = ucnv_open(name, &status);
00110   if (U_FAILURE(status))
00111     goto error;
00112 
00113   status = U_ZERO_ERROR;
00114   if (toUnicode) {
00115     ucnv_setToUCallBack(conv->uconv, UCNV_TO_U_CALLBACK_STOP,
00116                         NULL, NULL, NULL, &status);
00117   }
00118   else {
00119     ucnv_setFromUCallBack(conv->uconv, UCNV_FROM_U_CALLBACK_STOP,
00120                         NULL, NULL, NULL, &status);
00121   }
00122   if (U_FAILURE(status))
00123     goto error;
00124 
00125   status = U_ZERO_ERROR;
00126   conv->utf8 = ucnv_open("UTF-8", &status);
00127   if (U_SUCCESS(status))
00128     return conv;
00129 
00130 error:
00131   if (conv->uconv)
00132     ucnv_close(conv->uconv);
00133   xmlFree(conv);
00134   return NULL;
00135 }
00136 
00137 static void
00138 closeIcuConverter(uconv_t *conv)
00139 {
00140   if (conv != NULL) {
00141     ucnv_close(conv->uconv);
00142     ucnv_close(conv->utf8);
00143     xmlFree(conv);
00144   }
00145 }
00146 #endif /* LIBXML_ICU_ENABLED */
00147 
00148 /************************************************************************
00149  *                                  *
00150  *      Conversions To/From UTF8 encoding           *
00151  *                                  *
00152  ************************************************************************/
00153 
00168 static int
00169 asciiToUTF8(unsigned char* out, int *outlen,
00170               const unsigned char* in, int *inlen) {
00171     unsigned char* outstart = out;
00172     const unsigned char* base = in;
00173     const unsigned char* processed = in;
00174     unsigned char* outend = out + *outlen;
00175     const unsigned char* inend;
00176     unsigned int c;
00177 
00178     inend = in + (*inlen);
00179     while ((in < inend) && (out - outstart + 5 < *outlen)) {
00180     c= *in++;
00181 
00182         if (out >= outend)
00183         break;
00184         if (c < 0x80) {
00185         *out++ = c;
00186     } else {
00187         *outlen = out - outstart;
00188         *inlen = processed - base;
00189         return(-1);
00190     }
00191 
00192     processed = (const unsigned char*) in;
00193     }
00194     *outlen = out - outstart;
00195     *inlen = processed - base;
00196     return(*outlen);
00197 }
00198 
00199 #ifdef LIBXML_OUTPUT_ENABLED
00200 
00215 static int
00216 UTF8Toascii(unsigned char* out, int *outlen,
00217               const unsigned char* in, int *inlen) {
00218     const unsigned char* processed = in;
00219     const unsigned char* outend;
00220     const unsigned char* outstart = out;
00221     const unsigned char* instart = in;
00222     const unsigned char* inend;
00223     unsigned int c, d;
00224     int trailing;
00225 
00226     if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
00227     if (in == NULL) {
00228         /*
00229      * initialization nothing to do
00230      */
00231     *outlen = 0;
00232     *inlen = 0;
00233     return(0);
00234     }
00235     inend = in + (*inlen);
00236     outend = out + (*outlen);
00237     while (in < inend) {
00238     d = *in++;
00239     if      (d < 0x80)  { c= d; trailing= 0; }
00240     else if (d < 0xC0) {
00241         /* trailing byte in leading position */
00242         *outlen = out - outstart;
00243         *inlen = processed - instart;
00244         return(-2);
00245         } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
00246         else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
00247         else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
00248     else {
00249         /* no chance for this in Ascii */
00250         *outlen = out - outstart;
00251         *inlen = processed - instart;
00252         return(-2);
00253     }
00254 
00255     if (inend - in < trailing) {
00256         break;
00257     }
00258 
00259     for ( ; trailing; trailing--) {
00260         if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))
00261         break;
00262         c <<= 6;
00263         c |= d & 0x3F;
00264     }
00265 
00266     /* assertion: c is a single UTF-4 value */
00267     if (c < 0x80) {
00268         if (out >= outend)
00269         break;
00270         *out++ = c;
00271     } else {
00272         /* no chance for this in Ascii */
00273         *outlen = out - outstart;
00274         *inlen = processed - instart;
00275         return(-2);
00276     }
00277     processed = in;
00278     }
00279     *outlen = out - outstart;
00280     *inlen = processed - instart;
00281     return(*outlen);
00282 }
00283 #endif /* LIBXML_OUTPUT_ENABLED */
00284 
00299 int
00300 isolat1ToUTF8(unsigned char* out, int *outlen,
00301               const unsigned char* in, int *inlen) {
00302     unsigned char* outstart = out;
00303     const unsigned char* base = in;
00304     unsigned char* outend;
00305     const unsigned char* inend;
00306     const unsigned char* instop;
00307 
00308     if ((out == NULL) || (in == NULL) || (outlen == NULL) || (inlen == NULL))
00309     return(-1);
00310 
00311     outend = out + *outlen;
00312     inend = in + (*inlen);
00313     instop = inend;
00314 
00315     while ((in < inend) && (out < outend - 1)) {
00316     if (*in >= 0x80) {
00317         *out++ = (((*in) >>  6) & 0x1F) | 0xC0;
00318             *out++ = ((*in) & 0x3F) | 0x80;
00319         ++in;
00320     }
00321     if ((instop - in) > (outend - out)) instop = in + (outend - out);
00322     while ((in < instop) && (*in < 0x80)) {
00323         *out++ = *in++;
00324     }
00325     }
00326     if ((in < inend) && (out < outend) && (*in < 0x80)) {
00327         *out++ = *in++;
00328     }
00329     *outlen = out - outstart;
00330     *inlen = in - base;
00331     return(*outlen);
00332 }
00333 
00347 static int
00348 UTF8ToUTF8(unsigned char* out, int *outlen,
00349            const unsigned char* inb, int *inlenb)
00350 {
00351     int len;
00352 
00353     if ((out == NULL) || (inb == NULL) || (outlen == NULL) || (inlenb == NULL))
00354     return(-1);
00355     if (*outlen > *inlenb) {
00356     len = *inlenb;
00357     } else {
00358     len = *outlen;
00359     }
00360     if (len < 0)
00361     return(-1);
00362 
00363     memcpy(out, inb, len);
00364 
00365     *outlen = len;
00366     *inlenb = len;
00367     return(*outlen);
00368 }
00369 
00370 
00371 #ifdef LIBXML_OUTPUT_ENABLED
00372 
00388 int
00389 UTF8Toisolat1(unsigned char* out, int *outlen,
00390               const unsigned char* in, int *inlen) {
00391     const unsigned char* processed = in;
00392     const unsigned char* outend;
00393     const unsigned char* outstart = out;
00394     const unsigned char* instart = in;
00395     const unsigned char* inend;
00396     unsigned int c, d;
00397     int trailing;
00398 
00399     if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
00400     if (in == NULL) {
00401         /*
00402      * initialization nothing to do
00403      */
00404     *outlen = 0;
00405     *inlen = 0;
00406     return(0);
00407     }
00408     inend = in + (*inlen);
00409     outend = out + (*outlen);
00410     while (in < inend) {
00411     d = *in++;
00412     if      (d < 0x80)  { c= d; trailing= 0; }
00413     else if (d < 0xC0) {
00414         /* trailing byte in leading position */
00415         *outlen = out - outstart;
00416         *inlen = processed - instart;
00417         return(-2);
00418         } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
00419         else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
00420         else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
00421     else {
00422         /* no chance for this in IsoLat1 */
00423         *outlen = out - outstart;
00424         *inlen = processed - instart;
00425         return(-2);
00426     }
00427 
00428     if (inend - in < trailing) {
00429         break;
00430     }
00431 
00432     for ( ; trailing; trailing--) {
00433         if (in >= inend)
00434         break;
00435         if (((d= *in++) & 0xC0) != 0x80) {
00436         *outlen = out - outstart;
00437         *inlen = processed - instart;
00438         return(-2);
00439         }
00440         c <<= 6;
00441         c |= d & 0x3F;
00442     }
00443 
00444     /* assertion: c is a single UTF-4 value */
00445     if (c <= 0xFF) {
00446         if (out >= outend)
00447         break;
00448         *out++ = c;
00449     } else {
00450         /* no chance for this in IsoLat1 */
00451         *outlen = out - outstart;
00452         *inlen = processed - instart;
00453         return(-2);
00454     }
00455     processed = in;
00456     }
00457     *outlen = out - outstart;
00458     *inlen = processed - instart;
00459     return(*outlen);
00460 }
00461 #endif /* LIBXML_OUTPUT_ENABLED */
00462 
00480 static int
00481 UTF16LEToUTF8(unsigned char* out, int *outlen,
00482             const unsigned char* inb, int *inlenb)
00483 {
00484     unsigned char* outstart = out;
00485     const unsigned char* processed = inb;
00486     unsigned char* outend = out + *outlen;
00487     unsigned short* in = (unsigned short*) inb;
00488     unsigned short* inend;
00489     unsigned int c, d, inlen;
00490     unsigned char *tmp;
00491     int bits;
00492 
00493     if ((*inlenb % 2) == 1)
00494         (*inlenb)--;
00495     inlen = *inlenb / 2;
00496     inend = in + inlen;
00497     while ((in < inend) && (out - outstart + 5 < *outlen)) {
00498         if (xmlLittleEndian) {
00499         c= *in++;
00500     } else {
00501         tmp = (unsigned char *) in;
00502         c = *tmp++;
00503         c = c | (((unsigned int)*tmp) << 8);
00504         in++;
00505     }
00506         if ((c & 0xFC00) == 0xD800) {    /* surrogates */
00507         if (in >= inend) {           /* (in > inend) shouldn't happens */
00508         break;
00509         }
00510         if (xmlLittleEndian) {
00511         d = *in++;
00512         } else {
00513         tmp = (unsigned char *) in;
00514         d = *tmp++;
00515         d = d | (((unsigned int)*tmp) << 8);
00516         in++;
00517         }
00518             if ((d & 0xFC00) == 0xDC00) {
00519                 c &= 0x03FF;
00520                 c <<= 10;
00521                 c |= d & 0x03FF;
00522                 c += 0x10000;
00523             }
00524             else {
00525         *outlen = out - outstart;
00526         *inlenb = processed - inb;
00527             return(-2);
00528         }
00529         }
00530 
00531     /* assertion: c is a single UTF-4 value */
00532         if (out >= outend)
00533         break;
00534         if      (c <    0x80) {  *out++=  c;                bits= -6; }
00535         else if (c <   0x800) {  *out++= ((c >>  6) & 0x1F) | 0xC0;  bits=  0; }
00536         else if (c < 0x10000) {  *out++= ((c >> 12) & 0x0F) | 0xE0;  bits=  6; }
00537         else                  {  *out++= ((c >> 18) & 0x07) | 0xF0;  bits= 12; }
00538 
00539         for ( ; bits >= 0; bits-= 6) {
00540             if (out >= outend)
00541             break;
00542             *out++= ((c >> bits) & 0x3F) | 0x80;
00543         }
00544     processed = (const unsigned char*) in;
00545     }
00546     *outlen = out - outstart;
00547     *inlenb = processed - inb;
00548     return(*outlen);
00549 }
00550 
00551 #ifdef LIBXML_OUTPUT_ENABLED
00552 
00565 static int
00566 UTF8ToUTF16LE(unsigned char* outb, int *outlen,
00567             const unsigned char* in, int *inlen)
00568 {
00569     unsigned short* out = (unsigned short*) outb;
00570     const unsigned char* processed = in;
00571     const unsigned char *const instart = in;
00572     unsigned short* outstart= out;
00573     unsigned short* outend;
00574     const unsigned char* inend;
00575     unsigned int c, d;
00576     int trailing;
00577     unsigned char *tmp;
00578     unsigned short tmp1, tmp2;
00579 
00580     /* UTF16LE encoding has no BOM */
00581     if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
00582     if (in == NULL) {
00583     *outlen = 0;
00584     *inlen = 0;
00585     return(0);
00586     }
00587     inend= in + *inlen;
00588     outend = out + (*outlen / 2);
00589     while (in < inend) {
00590       d= *in++;
00591       if      (d < 0x80)  { c= d; trailing= 0; }
00592       else if (d < 0xC0) {
00593           /* trailing byte in leading position */
00594       *outlen = (out - outstart) * 2;
00595       *inlen = processed - instart;
00596       return(-2);
00597       } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
00598       else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
00599       else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
00600       else {
00601     /* no chance for this in UTF-16 */
00602     *outlen = (out - outstart) * 2;
00603     *inlen = processed - instart;
00604     return(-2);
00605       }
00606 
00607       if (inend - in < trailing) {
00608           break;
00609       }
00610 
00611       for ( ; trailing; trailing--) {
00612           if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))
00613           break;
00614           c <<= 6;
00615           c |= d & 0x3F;
00616       }
00617 
00618       /* assertion: c is a single UTF-4 value */
00619         if (c < 0x10000) {
00620             if (out >= outend)
00621             break;
00622         if (xmlLittleEndian) {
00623         *out++ = c;
00624         } else {
00625         tmp = (unsigned char *) out;
00626         *tmp = c ;
00627         *(tmp + 1) = c >> 8 ;
00628         out++;
00629         }
00630         }
00631         else if (c < 0x110000) {
00632             if (out+1 >= outend)
00633             break;
00634             c -= 0x10000;
00635         if (xmlLittleEndian) {
00636         *out++ = 0xD800 | (c >> 10);
00637         *out++ = 0xDC00 | (c & 0x03FF);
00638         } else {
00639         tmp1 = 0xD800 | (c >> 10);
00640         tmp = (unsigned char *) out;
00641         *tmp = (unsigned char) tmp1;
00642         *(tmp + 1) = tmp1 >> 8;
00643         out++;
00644 
00645         tmp2 = 0xDC00 | (c & 0x03FF);
00646         tmp = (unsigned char *) out;
00647         *tmp  = (unsigned char) tmp2;
00648         *(tmp + 1) = tmp2 >> 8;
00649         out++;
00650         }
00651         }
00652         else
00653         break;
00654     processed = in;
00655     }
00656     *outlen = (out - outstart) * 2;
00657     *inlen = processed - instart;
00658     return(*outlen);
00659 }
00660 
00674 static int
00675 UTF8ToUTF16(unsigned char* outb, int *outlen,
00676             const unsigned char* in, int *inlen)
00677 {
00678     if (in == NULL) {
00679     /*
00680      * initialization, add the Byte Order Mark for UTF-16LE
00681      */
00682         if (*outlen >= 2) {
00683         outb[0] = 0xFF;
00684         outb[1] = 0xFE;
00685         *outlen = 2;
00686         *inlen = 0;
00687 #ifdef DEBUG_ENCODING
00688             xmlGenericError(xmlGenericErrorContext,
00689             "Added FFFE Byte Order Mark\n");
00690 #endif
00691         return(2);
00692     }
00693     *outlen = 0;
00694     *inlen = 0;
00695     return(0);
00696     }
00697     return (UTF8ToUTF16LE(outb, outlen, in, inlen));
00698 }
00699 #endif /* LIBXML_OUTPUT_ENABLED */
00700 
00718 static int
00719 UTF16BEToUTF8(unsigned char* out, int *outlen,
00720             const unsigned char* inb, int *inlenb)
00721 {
00722     unsigned char* outstart = out;
00723     const unsigned char* processed = inb;
00724     unsigned char* outend = out + *outlen;
00725     unsigned short* in = (unsigned short*) inb;
00726     unsigned short* inend;
00727     unsigned int c, d, inlen;
00728     unsigned char *tmp;
00729     int bits;
00730 
00731     if ((*inlenb % 2) == 1)
00732         (*inlenb)--;
00733     inlen = *inlenb / 2;
00734     inend= in + inlen;
00735     while (in < inend) {
00736     if (xmlLittleEndian) {
00737         tmp = (unsigned char *) in;
00738         c = *tmp++;
00739         c = c << 8;
00740         c = c | (unsigned int) *tmp;
00741         in++;
00742     } else {
00743         c= *in++;
00744     }
00745         if ((c & 0xFC00) == 0xD800) {    /* surrogates */
00746         if (in >= inend) {           /* (in > inend) shouldn't happens */
00747         *outlen = out - outstart;
00748         *inlenb = processed - inb;
00749             return(-2);
00750         }
00751         if (xmlLittleEndian) {
00752         tmp = (unsigned char *) in;
00753         d = *tmp++;
00754         d = d << 8;
00755         d = d | (unsigned int) *tmp;
00756         in++;
00757         } else {
00758         d= *in++;
00759         }
00760             if ((d & 0xFC00) == 0xDC00) {
00761                 c &= 0x03FF;
00762                 c <<= 10;
00763                 c |= d & 0x03FF;
00764                 c += 0x10000;
00765             }
00766             else {
00767         *outlen = out - outstart;
00768         *inlenb = processed - inb;
00769             return(-2);
00770         }
00771         }
00772 
00773     /* assertion: c is a single UTF-4 value */
00774         if (out >= outend)
00775         break;
00776         if      (c <    0x80) {  *out++=  c;                bits= -6; }
00777         else if (c <   0x800) {  *out++= ((c >>  6) & 0x1F) | 0xC0;  bits=  0; }
00778         else if (c < 0x10000) {  *out++= ((c >> 12) & 0x0F) | 0xE0;  bits=  6; }
00779         else                  {  *out++= ((c >> 18) & 0x07) | 0xF0;  bits= 12; }
00780 
00781         for ( ; bits >= 0; bits-= 6) {
00782             if (out >= outend)
00783             break;
00784             *out++= ((c >> bits) & 0x3F) | 0x80;
00785         }
00786     processed = (const unsigned char*) in;
00787     }
00788     *outlen = out - outstart;
00789     *inlenb = processed - inb;
00790     return(*outlen);
00791 }
00792 
00793 #ifdef LIBXML_OUTPUT_ENABLED
00794 
00807 static int
00808 UTF8ToUTF16BE(unsigned char* outb, int *outlen,
00809             const unsigned char* in, int *inlen)
00810 {
00811     unsigned short* out = (unsigned short*) outb;
00812     const unsigned char* processed = in;
00813     const unsigned char *const instart = in;
00814     unsigned short* outstart= out;
00815     unsigned short* outend;
00816     const unsigned char* inend;
00817     unsigned int c, d;
00818     int trailing;
00819     unsigned char *tmp;
00820     unsigned short tmp1, tmp2;
00821 
00822     /* UTF-16BE has no BOM */
00823     if ((outb == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
00824     if (in == NULL) {
00825     *outlen = 0;
00826     *inlen = 0;
00827     return(0);
00828     }
00829     inend= in + *inlen;
00830     outend = out + (*outlen / 2);
00831     while (in < inend) {
00832       d= *in++;
00833       if      (d < 0x80)  { c= d; trailing= 0; }
00834       else if (d < 0xC0)  {
00835           /* trailing byte in leading position */
00836       *outlen = out - outstart;
00837       *inlen = processed - instart;
00838       return(-2);
00839       } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
00840       else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
00841       else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
00842       else {
00843           /* no chance for this in UTF-16 */
00844       *outlen = out - outstart;
00845       *inlen = processed - instart;
00846       return(-2);
00847       }
00848 
00849       if (inend - in < trailing) {
00850           break;
00851       }
00852 
00853       for ( ; trailing; trailing--) {
00854           if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))  break;
00855           c <<= 6;
00856           c |= d & 0x3F;
00857       }
00858 
00859       /* assertion: c is a single UTF-4 value */
00860         if (c < 0x10000) {
00861             if (out >= outend)  break;
00862         if (xmlLittleEndian) {
00863         tmp = (unsigned char *) out;
00864         *tmp = c >> 8;
00865         *(tmp + 1) = c;
00866         out++;
00867         } else {
00868         *out++ = c;
00869         }
00870         }
00871         else if (c < 0x110000) {
00872             if (out+1 >= outend)  break;
00873             c -= 0x10000;
00874         if (xmlLittleEndian) {
00875         tmp1 = 0xD800 | (c >> 10);
00876         tmp = (unsigned char *) out;
00877         *tmp = tmp1 >> 8;
00878         *(tmp + 1) = (unsigned char) tmp1;
00879         out++;
00880 
00881         tmp2 = 0xDC00 | (c & 0x03FF);
00882         tmp = (unsigned char *) out;
00883         *tmp = tmp2 >> 8;
00884         *(tmp + 1) = (unsigned char) tmp2;
00885         out++;
00886         } else {
00887         *out++ = 0xD800 | (c >> 10);
00888         *out++ = 0xDC00 | (c & 0x03FF);
00889         }
00890         }
00891         else
00892         break;
00893     processed = in;
00894     }
00895     *outlen = (out - outstart) * 2;
00896     *inlen = processed - instart;
00897     return(*outlen);
00898 }
00899 #endif /* LIBXML_OUTPUT_ENABLED */
00900 
00901 /************************************************************************
00902  *                                  *
00903  *      Generic encoding handling routines          *
00904  *                                  *
00905  ************************************************************************/
00906 
00918 xmlCharEncoding
00919 xmlDetectCharEncoding(const unsigned char* in, int len)
00920 {
00921     if (in == NULL)
00922         return(XML_CHAR_ENCODING_NONE);
00923     if (len >= 4) {
00924     if ((in[0] == 0x00) && (in[1] == 0x00) &&
00925         (in[2] == 0x00) && (in[3] == 0x3C))
00926         return(XML_CHAR_ENCODING_UCS4BE);
00927     if ((in[0] == 0x3C) && (in[1] == 0x00) &&
00928         (in[2] == 0x00) && (in[3] == 0x00))
00929         return(XML_CHAR_ENCODING_UCS4LE);
00930     if ((in[0] == 0x00) && (in[1] == 0x00) &&
00931         (in[2] == 0x3C) && (in[3] == 0x00))
00932         return(XML_CHAR_ENCODING_UCS4_2143);
00933     if ((in[0] == 0x00) && (in[1] == 0x3C) &&
00934         (in[2] == 0x00) && (in[3] == 0x00))
00935         return(XML_CHAR_ENCODING_UCS4_3412);
00936     if ((in[0] == 0x4C) && (in[1] == 0x6F) &&
00937         (in[2] == 0xA7) && (in[3] == 0x94))
00938         return(XML_CHAR_ENCODING_EBCDIC);
00939     if ((in[0] == 0x3C) && (in[1] == 0x3F) &&
00940         (in[2] == 0x78) && (in[3] == 0x6D))
00941         return(XML_CHAR_ENCODING_UTF8);
00942     /*
00943      * Although not part of the recommendation, we also
00944      * attempt an "auto-recognition" of UTF-16LE and
00945      * UTF-16BE encodings.
00946      */
00947     if ((in[0] == 0x3C) && (in[1] == 0x00) &&
00948         (in[2] == 0x3F) && (in[3] == 0x00))
00949         return(XML_CHAR_ENCODING_UTF16LE);
00950     if ((in[0] == 0x00) && (in[1] == 0x3C) &&
00951         (in[2] == 0x00) && (in[3] == 0x3F))
00952         return(XML_CHAR_ENCODING_UTF16BE);
00953     }
00954     if (len >= 3) {
00955     /*
00956      * Errata on XML-1.0 June 20 2001
00957      * We now allow an UTF8 encoded BOM
00958      */
00959     if ((in[0] == 0xEF) && (in[1] == 0xBB) &&
00960         (in[2] == 0xBF))
00961         return(XML_CHAR_ENCODING_UTF8);
00962     }
00963     /* For UTF-16 we can recognize by the BOM */
00964     if (len >= 2) {
00965     if ((in[0] == 0xFE) && (in[1] == 0xFF))
00966         return(XML_CHAR_ENCODING_UTF16BE);
00967     if ((in[0] == 0xFF) && (in[1] == 0xFE))
00968         return(XML_CHAR_ENCODING_UTF16LE);
00969     }
00970     return(XML_CHAR_ENCODING_NONE);
00971 }
00972 
00978 void
00979 xmlCleanupEncodingAliases(void) {
00980     int i;
00981 
00982     if (xmlCharEncodingAliases == NULL)
00983     return;
00984 
00985     for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
00986     if (xmlCharEncodingAliases[i].name != NULL)
00987         xmlFree((char *) xmlCharEncodingAliases[i].name);
00988     if (xmlCharEncodingAliases[i].alias != NULL)
00989         xmlFree((char *) xmlCharEncodingAliases[i].alias);
00990     }
00991     xmlCharEncodingAliasesNb = 0;
00992     xmlCharEncodingAliasesMax = 0;
00993     xmlFree(xmlCharEncodingAliases);
00994     xmlCharEncodingAliases = NULL;
00995 }
00996 
01005 const char *
01006 xmlGetEncodingAlias(const char *alias) {
01007     int i;
01008     char upper[100];
01009 
01010     if (alias == NULL)
01011     return(NULL);
01012 
01013     if (xmlCharEncodingAliases == NULL)
01014     return(NULL);
01015 
01016     for (i = 0;i < 99;i++) {
01017         upper[i] = toupper(alias[i]);
01018     if (upper[i] == 0) break;
01019     }
01020     upper[i] = 0;
01021 
01022     /*
01023      * Walk down the list looking for a definition of the alias
01024      */
01025     for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
01026     if (!strcmp(xmlCharEncodingAliases[i].alias, upper)) {
01027         return(xmlCharEncodingAliases[i].name);
01028     }
01029     }
01030     return(NULL);
01031 }
01032 
01043 int
01044 xmlAddEncodingAlias(const char *name, const char *alias) {
01045     int i;
01046     char upper[100];
01047 
01048     if ((name == NULL) || (alias == NULL))
01049     return(-1);
01050 
01051     for (i = 0;i < 99;i++) {
01052         upper[i] = toupper(alias[i]);
01053     if (upper[i] == 0) break;
01054     }
01055     upper[i] = 0;
01056 
01057     if (xmlCharEncodingAliases == NULL) {
01058     xmlCharEncodingAliasesNb = 0;
01059     xmlCharEncodingAliasesMax = 20;
01060     xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
01061           xmlMalloc(xmlCharEncodingAliasesMax * sizeof(xmlCharEncodingAlias));
01062     if (xmlCharEncodingAliases == NULL)
01063         return(-1);
01064     } else if (xmlCharEncodingAliasesNb >= xmlCharEncodingAliasesMax) {
01065     xmlCharEncodingAliasesMax *= 2;
01066     xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
01067           xmlRealloc(xmlCharEncodingAliases,
01068                  xmlCharEncodingAliasesMax * sizeof(xmlCharEncodingAlias));
01069     }
01070     /*
01071      * Walk down the list looking for a definition of the alias
01072      */
01073     for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
01074     if (!strcmp(xmlCharEncodingAliases[i].alias, upper)) {
01075         /*
01076          * Replace the definition.
01077          */
01078         xmlFree((char *) xmlCharEncodingAliases[i].name);
01079         xmlCharEncodingAliases[i].name = xmlMemStrdup(name);
01080         return(0);
01081     }
01082     }
01083     /*
01084      * Add the definition
01085      */
01086     xmlCharEncodingAliases[xmlCharEncodingAliasesNb].name = xmlMemStrdup(name);
01087     xmlCharEncodingAliases[xmlCharEncodingAliasesNb].alias = xmlMemStrdup(upper);
01088     xmlCharEncodingAliasesNb++;
01089     return(0);
01090 }
01091 
01100 int
01101 xmlDelEncodingAlias(const char *alias) {
01102     int i;
01103 
01104     if (alias == NULL)
01105     return(-1);
01106 
01107     if (xmlCharEncodingAliases == NULL)
01108     return(-1);
01109     /*
01110      * Walk down the list looking for a definition of the alias
01111      */
01112     for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
01113     if (!strcmp(xmlCharEncodingAliases[i].alias, alias)) {
01114         xmlFree((char *) xmlCharEncodingAliases[i].name);
01115         xmlFree((char *) xmlCharEncodingAliases[i].alias);
01116         xmlCharEncodingAliasesNb--;
01117         memmove(&xmlCharEncodingAliases[i], &xmlCharEncodingAliases[i + 1],
01118             sizeof(xmlCharEncodingAlias) * (xmlCharEncodingAliasesNb - i));
01119         return(0);
01120     }
01121     }
01122     return(-1);
01123 }
01124 
01136 xmlCharEncoding
01137 xmlParseCharEncoding(const char* name)
01138 {
01139     const char *alias;
01140     char upper[500];
01141     int i;
01142 
01143     if (name == NULL)
01144     return(XML_CHAR_ENCODING_NONE);
01145 
01146     /*
01147      * Do the alias resolution
01148      */
01149     alias = xmlGetEncodingAlias(name);
01150     if (alias != NULL)
01151     name = alias;
01152 
01153     for (i = 0;i < 499;i++) {
01154         upper[i] = toupper(name[i]);
01155     if (upper[i] == 0) break;
01156     }
01157     upper[i] = 0;
01158 
01159     if (!strcmp(upper, "")) return(XML_CHAR_ENCODING_NONE);
01160     if (!strcmp(upper, "UTF-8")) return(XML_CHAR_ENCODING_UTF8);
01161     if (!strcmp(upper, "UTF8")) return(XML_CHAR_ENCODING_UTF8);
01162 
01163     /*
01164      * NOTE: if we were able to parse this, the endianness of UTF16 is
01165      *       already found and in use
01166      */
01167     if (!strcmp(upper, "UTF-16")) return(XML_CHAR_ENCODING_UTF16LE);
01168     if (!strcmp(upper, "UTF16")) return(XML_CHAR_ENCODING_UTF16LE);
01169 
01170     if (!strcmp(upper, "ISO-10646-UCS-2")) return(XML_CHAR_ENCODING_UCS2);
01171     if (!strcmp(upper, "UCS-2")) return(XML_CHAR_ENCODING_UCS2);
01172     if (!strcmp(upper, "UCS2")) return(XML_CHAR_ENCODING_UCS2);
01173 
01174     /*
01175      * NOTE: if we were able to parse this, the endianness of UCS4 is
01176      *       already found and in use
01177      */
01178     if (!strcmp(upper, "ISO-10646-UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
01179     if (!strcmp(upper, "UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
01180     if (!strcmp(upper, "UCS4")) return(XML_CHAR_ENCODING_UCS4LE);
01181 
01182 
01183     if (!strcmp(upper,  "ISO-8859-1")) return(XML_CHAR_ENCODING_8859_1);
01184     if (!strcmp(upper,  "ISO-LATIN-1")) return(XML_CHAR_ENCODING_8859_1);
01185     if (!strcmp(upper,  "ISO LATIN 1")) return(XML_CHAR_ENCODING_8859_1);
01186 
01187     if (!strcmp(upper,  "ISO-8859-2")) return(XML_CHAR_ENCODING_8859_2);
01188     if (!strcmp(upper,  "ISO-LATIN-2")) return(XML_CHAR_ENCODING_8859_2);
01189     if (!strcmp(upper,  "ISO LATIN 2")) return(XML_CHAR_ENCODING_8859_2);
01190 
01191     if (!strcmp(upper,  "ISO-8859-3")) return(XML_CHAR_ENCODING_8859_3);
01192     if (!strcmp(upper,  "ISO-8859-4")) return(XML_CHAR_ENCODING_8859_4);
01193     if (!strcmp(upper,  "ISO-8859-5")) return(XML_CHAR_ENCODING_8859_5);
01194     if (!strcmp(upper,  "ISO-8859-6")) return(XML_CHAR_ENCODING_8859_6);
01195     if (!strcmp(upper,  "ISO-8859-7")) return(XML_CHAR_ENCODING_8859_7);
01196     if (!strcmp(upper,  "ISO-8859-8")) return(XML_CHAR_ENCODING_8859_8);
01197     if (!strcmp(upper,  "ISO-8859-9")) return(XML_CHAR_ENCODING_8859_9);
01198 
01199     if (!strcmp(upper, "ISO-2022-JP")) return(XML_CHAR_ENCODING_2022_JP);
01200     if (!strcmp(upper, "SHIFT_JIS")) return(XML_CHAR_ENCODING_SHIFT_JIS);
01201     if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
01202 
01203 #ifdef DEBUG_ENCODING
01204     xmlGenericError(xmlGenericErrorContext, "Unknown encoding %s\n", name);
01205 #endif
01206     return(XML_CHAR_ENCODING_ERROR);
01207 }
01208 
01220 const char*
01221 xmlGetCharEncodingName(xmlCharEncoding enc) {
01222     switch (enc) {
01223         case XML_CHAR_ENCODING_ERROR:
01224         return(NULL);
01225         case XML_CHAR_ENCODING_NONE:
01226         return(NULL);
01227         case XML_CHAR_ENCODING_UTF8:
01228         return("UTF-8");
01229         case XML_CHAR_ENCODING_UTF16LE:
01230         return("UTF-16");
01231         case XML_CHAR_ENCODING_UTF16BE:
01232         return("UTF-16");
01233         case XML_CHAR_ENCODING_EBCDIC:
01234             return("EBCDIC");
01235         case XML_CHAR_ENCODING_UCS4LE:
01236             return("ISO-10646-UCS-4");
01237         case XML_CHAR_ENCODING_UCS4BE:
01238             return("ISO-10646-UCS-4");
01239         case XML_CHAR_ENCODING_UCS4_2143:
01240             return("ISO-10646-UCS-4");
01241         case XML_CHAR_ENCODING_UCS4_3412:
01242             return("ISO-10646-UCS-4");
01243         case XML_CHAR_ENCODING_UCS2:
01244             return("ISO-10646-UCS-2");
01245         case XML_CHAR_ENCODING_8859_1:
01246         return("ISO-8859-1");
01247         case XML_CHAR_ENCODING_8859_2:
01248         return("ISO-8859-2");
01249         case XML_CHAR_ENCODING_8859_3:
01250         return("ISO-8859-3");
01251         case XML_CHAR_ENCODING_8859_4:
01252         return("ISO-8859-4");
01253         case XML_CHAR_ENCODING_8859_5:
01254         return("ISO-8859-5");
01255         case XML_CHAR_ENCODING_8859_6:
01256         return("ISO-8859-6");
01257         case XML_CHAR_ENCODING_8859_7:
01258         return("ISO-8859-7");
01259         case XML_CHAR_ENCODING_8859_8:
01260         return("ISO-8859-8");
01261         case XML_CHAR_ENCODING_8859_9:
01262         return("ISO-8859-9");
01263         case XML_CHAR_ENCODING_2022_JP:
01264             return("ISO-2022-JP");
01265         case XML_CHAR_ENCODING_SHIFT_JIS:
01266             return("Shift-JIS");
01267         case XML_CHAR_ENCODING_EUC_JP:
01268             return("EUC-JP");
01269     case XML_CHAR_ENCODING_ASCII:
01270         return(NULL);
01271     }
01272     return(NULL);
01273 }
01274 
01275 /************************************************************************
01276  *                                  *
01277  *          Char encoding handlers              *
01278  *                                  *
01279  ************************************************************************/
01280 
01281 
01282 /* the size should be growable, but it's not a big deal ... */
01283 #define MAX_ENCODING_HANDLERS 50
01284 static xmlCharEncodingHandlerPtr *handlers = NULL;
01285 static int nbCharEncodingHandler = 0;
01286 
01287 /*
01288  * The default is UTF-8 for XML, that's also the default used for the
01289  * parser internals, so the default encoding handler is NULL
01290  */
01291 
01292 static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL;
01293 
01304 xmlCharEncodingHandlerPtr
01305 xmlNewCharEncodingHandler(const char *name,
01306                           xmlCharEncodingInputFunc input,
01307                           xmlCharEncodingOutputFunc output) {
01308     xmlCharEncodingHandlerPtr handler;
01309     const char *alias;
01310     char upper[500];
01311     int i;
01312     char *up = NULL;
01313 
01314     /*
01315      * Do the alias resolution
01316      */
01317     alias = xmlGetEncodingAlias(name);
01318     if (alias != NULL)
01319     name = alias;
01320 
01321     /*
01322      * Keep only the uppercase version of the encoding.
01323      */
01324     if (name == NULL) {
01325         xmlEncodingErr(XML_I18N_NO_NAME,
01326                "xmlNewCharEncodingHandler : no name !\n", NULL);
01327     return(NULL);
01328     }
01329     for (i = 0;i < 499;i++) {
01330         upper[i] = toupper(name[i]);
01331     if (upper[i] == 0) break;
01332     }
01333     upper[i] = 0;
01334     up = xmlMemStrdup(upper);
01335     if (up == NULL) {
01336         xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
01337     return(NULL);
01338     }
01339 
01340     /*
01341      * allocate and fill-up an handler block.
01342      */
01343     handler = (xmlCharEncodingHandlerPtr)
01344               xmlMalloc(sizeof(xmlCharEncodingHandler));
01345     if (handler == NULL) {
01346         xmlFree(up);
01347         xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
01348     return(NULL);
01349     }
01350     memset(handler, 0, sizeof(xmlCharEncodingHandler));
01351     handler->input = input;
01352     handler->output = output;
01353     handler->name = up;
01354 
01355 #ifdef LIBXML_ICONV_ENABLED
01356     handler->iconv_in = NULL;
01357     handler->iconv_out = NULL;
01358 #endif
01359 #ifdef LIBXML_ICU_ENABLED
01360     handler->uconv_in = NULL;
01361     handler->uconv_out = NULL;
01362 #endif
01363 
01364     /*
01365      * registers and returns the handler.
01366      */
01367     xmlRegisterCharEncodingHandler(handler);
01368 #ifdef DEBUG_ENCODING
01369     xmlGenericError(xmlGenericErrorContext,
01370         "Registered encoding handler for %s\n", name);
01371 #endif
01372     return(handler);
01373 }
01374 
01383 void
01384 xmlInitCharEncodingHandlers(void) {
01385     unsigned short int tst = 0x1234;
01386     unsigned char *ptr = (unsigned char *) &tst;
01387 
01388     if (handlers != NULL) return;
01389 
01390     handlers = (xmlCharEncodingHandlerPtr *)
01391         xmlMalloc(MAX_ENCODING_HANDLERS * sizeof(xmlCharEncodingHandlerPtr));
01392 
01393     if (*ptr == 0x12) xmlLittleEndian = 0;
01394     else if (*ptr == 0x34) xmlLittleEndian = 1;
01395     else {
01396         xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
01397                    "Odd problem at endianness detection\n", NULL);
01398     }
01399 
01400     if (handlers == NULL) {
01401         xmlEncodingErrMemory("xmlInitCharEncodingHandlers : out of memory !\n");
01402     return;
01403     }
01404     xmlNewCharEncodingHandler("UTF-8", UTF8ToUTF8, UTF8ToUTF8);
01405 #ifdef LIBXML_OUTPUT_ENABLED
01406     xmlUTF16LEHandler =
01407           xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE);
01408     xmlUTF16BEHandler =
01409           xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, UTF8ToUTF16BE);
01410     xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, UTF8ToUTF16);
01411     xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1);
01412     xmlNewCharEncodingHandler("ASCII", asciiToUTF8, UTF8Toascii);
01413     xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, UTF8Toascii);
01414 #ifdef LIBXML_HTML_ENABLED
01415     xmlNewCharEncodingHandler("HTML", NULL, UTF8ToHtml);
01416 #endif
01417 #else
01418     xmlUTF16LEHandler =
01419           xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, NULL);
01420     xmlUTF16BEHandler =
01421           xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, NULL);
01422     xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, NULL);
01423     xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, NULL);
01424     xmlNewCharEncodingHandler("ASCII", asciiToUTF8, NULL);
01425     xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, NULL);
01426 #endif /* LIBXML_OUTPUT_ENABLED */
01427 #if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
01428 #ifdef LIBXML_ISO8859X_ENABLED
01429     xmlRegisterCharEncodingHandlersISO8859x ();
01430 #endif
01431 #endif
01432 
01433 }
01434 
01441 void
01442 xmlCleanupCharEncodingHandlers(void) {
01443     xmlCleanupEncodingAliases();
01444 
01445     if (handlers == NULL) return;
01446 
01447     for (;nbCharEncodingHandler > 0;) {
01448         nbCharEncodingHandler--;
01449     if (handlers[nbCharEncodingHandler] != NULL) {
01450         if (handlers[nbCharEncodingHandler]->name != NULL)
01451         xmlFree(handlers[nbCharEncodingHandler]->name);
01452         xmlFree(handlers[nbCharEncodingHandler]);
01453     }
01454     }
01455     xmlFree(handlers);
01456     handlers = NULL;
01457     nbCharEncodingHandler = 0;
01458     xmlDefaultCharEncodingHandler = NULL;
01459 }
01460 
01467 void
01468 xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
01469     if (handlers == NULL) xmlInitCharEncodingHandlers();
01470     if ((handler == NULL) || (handlers == NULL)) {
01471         xmlEncodingErr(XML_I18N_NO_HANDLER,
01472         "xmlRegisterCharEncodingHandler: NULL handler !\n", NULL);
01473     return;
01474     }
01475 
01476     if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) {
01477         xmlEncodingErr(XML_I18N_EXCESS_HANDLER,
01478     "xmlRegisterCharEncodingHandler: Too many handler registered, see %s\n",
01479                    "MAX_ENCODING_HANDLERS");
01480     return;
01481     }
01482     handlers[nbCharEncodingHandler++] = handler;
01483 }
01484 
01493 xmlCharEncodingHandlerPtr
01494 xmlGetCharEncodingHandler(xmlCharEncoding enc) {
01495     xmlCharEncodingHandlerPtr handler;
01496 
01497     if (handlers == NULL) xmlInitCharEncodingHandlers();
01498     switch (enc) {
01499         case XML_CHAR_ENCODING_ERROR:
01500         return(NULL);
01501         case XML_CHAR_ENCODING_NONE:
01502         return(NULL);
01503         case XML_CHAR_ENCODING_UTF8:
01504         return(NULL);
01505         case XML_CHAR_ENCODING_UTF16LE:
01506         return(xmlUTF16LEHandler);
01507         case XML_CHAR_ENCODING_UTF16BE:
01508         return(xmlUTF16BEHandler);
01509         case XML_CHAR_ENCODING_EBCDIC:
01510             handler = xmlFindCharEncodingHandler("EBCDIC");
01511             if (handler != NULL) return(handler);
01512             handler = xmlFindCharEncodingHandler("ebcdic");
01513             if (handler != NULL) return(handler);
01514             handler = xmlFindCharEncodingHandler("EBCDIC-US");
01515             if (handler != NULL) return(handler);
01516         break;
01517         case XML_CHAR_ENCODING_UCS4BE:
01518             handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
01519             if (handler != NULL) return(handler);
01520             handler = xmlFindCharEncodingHandler("UCS-4");
01521             if (handler != NULL) return(handler);
01522             handler = xmlFindCharEncodingHandler("UCS4");
01523             if (handler != NULL) return(handler);
01524         break;
01525         case XML_CHAR_ENCODING_UCS4LE:
01526             handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
01527             if (handler != NULL) return(handler);
01528             handler = xmlFindCharEncodingHandler("UCS-4");
01529             if (handler != NULL) return(handler);
01530             handler = xmlFindCharEncodingHandler("UCS4");
01531             if (handler != NULL) return(handler);
01532         break;
01533         case XML_CHAR_ENCODING_UCS4_2143:
01534         break;
01535         case XML_CHAR_ENCODING_UCS4_3412:
01536         break;
01537         case XML_CHAR_ENCODING_UCS2:
01538             handler = xmlFindCharEncodingHandler("ISO-10646-UCS-2");
01539             if (handler != NULL) return(handler);
01540             handler = xmlFindCharEncodingHandler("UCS-2");
01541             if (handler != NULL) return(handler);
01542             handler = xmlFindCharEncodingHandler("UCS2");
01543             if (handler != NULL) return(handler);
01544         break;
01545 
01546         /*
01547          * We used to keep ISO Latin encodings native in the
01548          * generated data. This led to so many problems that
01549          * this has been removed. One can still change this
01550          * back by registering no-ops encoders for those
01551          */
01552         case XML_CHAR_ENCODING_8859_1:
01553         handler = xmlFindCharEncodingHandler("ISO-8859-1");
01554         if (handler != NULL) return(handler);
01555         break;
01556         case XML_CHAR_ENCODING_8859_2:
01557         handler = xmlFindCharEncodingHandler("ISO-8859-2");
01558         if (handler != NULL) return(handler);
01559         break;
01560         case XML_CHAR_ENCODING_8859_3:
01561         handler = xmlFindCharEncodingHandler("ISO-8859-3");
01562         if (handler != NULL) return(handler);
01563         break;
01564         case XML_CHAR_ENCODING_8859_4:
01565         handler = xmlFindCharEncodingHandler("ISO-8859-4");
01566         if (handler != NULL) return(handler);
01567         break;
01568         case XML_CHAR_ENCODING_8859_5:
01569         handler = xmlFindCharEncodingHandler("ISO-8859-5");
01570         if (handler != NULL) return(handler);
01571         break;
01572         case XML_CHAR_ENCODING_8859_6:
01573         handler = xmlFindCharEncodingHandler("ISO-8859-6");
01574         if (handler != NULL) return(handler);
01575         break;
01576         case XML_CHAR_ENCODING_8859_7:
01577         handler = xmlFindCharEncodingHandler("ISO-8859-7");
01578         if (handler != NULL) return(handler);
01579         break;
01580         case XML_CHAR_ENCODING_8859_8:
01581         handler = xmlFindCharEncodingHandler("ISO-8859-8");
01582         if (handler != NULL) return(handler);
01583         break;
01584         case XML_CHAR_ENCODING_8859_9:
01585         handler = xmlFindCharEncodingHandler("ISO-8859-9");
01586         if (handler != NULL) return(handler);
01587         break;
01588 
01589 
01590         case XML_CHAR_ENCODING_2022_JP:
01591             handler = xmlFindCharEncodingHandler("ISO-2022-JP");
01592             if (handler != NULL) return(handler);
01593         break;
01594         case XML_CHAR_ENCODING_SHIFT_JIS:
01595             handler = xmlFindCharEncodingHandler("SHIFT-JIS");
01596             if (handler != NULL) return(handler);
01597             handler = xmlFindCharEncodingHandler("SHIFT_JIS");
01598             if (handler != NULL) return(handler);
01599             handler = xmlFindCharEncodingHandler("Shift_JIS");
01600             if (handler != NULL) return(handler);
01601         break;
01602         case XML_CHAR_ENCODING_EUC_JP:
01603             handler = xmlFindCharEncodingHandler("EUC-JP");
01604             if (handler != NULL) return(handler);
01605         break;
01606     default:
01607         break;
01608     }
01609 
01610 #ifdef DEBUG_ENCODING
01611     xmlGenericError(xmlGenericErrorContext,
01612         "No handler found for encoding %d\n", enc);
01613 #endif
01614     return(NULL);
01615 }
01616 
01625 xmlCharEncodingHandlerPtr
01626 xmlFindCharEncodingHandler(const char *name) {
01627     const char *nalias;
01628     const char *norig;
01629     xmlCharEncoding alias;
01630 #ifdef LIBXML_ICONV_ENABLED
01631     xmlCharEncodingHandlerPtr enc;
01632     iconv_t icv_in, icv_out;
01633 #endif /* LIBXML_ICONV_ENABLED */
01634 #ifdef LIBXML_ICU_ENABLED
01635     xmlCharEncodingHandlerPtr encu;
01636     uconv_t *ucv_in, *ucv_out;
01637 #endif /* LIBXML_ICU_ENABLED */
01638     char upper[100];
01639     int i;
01640 
01641     if (handlers == NULL) xmlInitCharEncodingHandlers();
01642     if (name == NULL) return(xmlDefaultCharEncodingHandler);
01643     if (name[0] == 0) return(xmlDefaultCharEncodingHandler);
01644 
01645     /*
01646      * Do the alias resolution
01647      */
01648     norig = name;
01649     nalias = xmlGetEncodingAlias(name);
01650     if (nalias != NULL)
01651     name = nalias;
01652 
01653     /*
01654      * Check first for directly registered encoding names
01655      */
01656     for (i = 0;i < 99;i++) {
01657         upper[i] = toupper(name[i]);
01658     if (upper[i] == 0) break;
01659     }
01660     upper[i] = 0;
01661 
01662     if (handlers != NULL) {
01663         for (i = 0;i < nbCharEncodingHandler; i++) {
01664             if (!strcmp(upper, handlers[i]->name)) {
01665 #ifdef DEBUG_ENCODING
01666                 xmlGenericError(xmlGenericErrorContext,
01667                         "Found registered handler for encoding %s\n", name);
01668 #endif
01669                 return(handlers[i]);
01670             }
01671         }
01672     }
01673 
01674 #ifdef LIBXML_ICONV_ENABLED
01675     /* check whether iconv can handle this */
01676     icv_in = iconv_open("UTF-8", name);
01677     icv_out = iconv_open(name, "UTF-8");
01678     if (icv_in == (iconv_t) -1) {
01679         icv_in = iconv_open("UTF-8", upper);
01680     }
01681     if (icv_out == (iconv_t) -1) {
01682     icv_out = iconv_open(upper, "UTF-8");
01683     }
01684     if ((icv_in != (iconv_t) -1) && (icv_out != (iconv_t) -1)) {
01685         enc = (xmlCharEncodingHandlerPtr)
01686               xmlMalloc(sizeof(xmlCharEncodingHandler));
01687         if (enc == NULL) {
01688             iconv_close(icv_in);
01689             iconv_close(icv_out);
01690         return(NULL);
01691         }
01692             memset(enc, 0, sizeof(xmlCharEncodingHandler));
01693         enc->name = xmlMemStrdup(name);
01694         enc->input = NULL;
01695         enc->output = NULL;
01696         enc->iconv_in = icv_in;
01697         enc->iconv_out = icv_out;
01698 #ifdef DEBUG_ENCODING
01699             xmlGenericError(xmlGenericErrorContext,
01700             "Found iconv handler for encoding %s\n", name);
01701 #endif
01702         return enc;
01703     } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
01704         xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
01705             "iconv : problems with filters for '%s'\n", name);
01706     }
01707 #endif /* LIBXML_ICONV_ENABLED */
01708 #ifdef LIBXML_ICU_ENABLED
01709     /* check whether icu can handle this */
01710     ucv_in = openIcuConverter(name, 1);
01711     ucv_out = openIcuConverter(name, 0);
01712     if (ucv_in != NULL && ucv_out != NULL) {
01713         encu = (xmlCharEncodingHandlerPtr)
01714                xmlMalloc(sizeof(xmlCharEncodingHandler));
01715         if (encu == NULL) {
01716                 closeIcuConverter(ucv_in);
01717                 closeIcuConverter(ucv_out);
01718         return(NULL);
01719         }
01720             memset(encu, 0, sizeof(xmlCharEncodingHandler));
01721         encu->name = xmlMemStrdup(name);
01722         encu->input = NULL;
01723         encu->output = NULL;
01724         encu->uconv_in = ucv_in;
01725         encu->uconv_out = ucv_out;
01726 #ifdef DEBUG_ENCODING
01727             xmlGenericError(xmlGenericErrorContext,
01728             "Found ICU converter handler for encoding %s\n", name);
01729 #endif
01730         return encu;
01731     } else if (ucv_in != NULL || ucv_out != NULL) {
01732             closeIcuConverter(ucv_in);
01733             closeIcuConverter(ucv_out);
01734         xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
01735             "ICU converter : problems with filters for '%s'\n", name);
01736     }
01737 #endif /* LIBXML_ICU_ENABLED */
01738 
01739 #ifdef DEBUG_ENCODING
01740     xmlGenericError(xmlGenericErrorContext,
01741         "No handler found for encoding %s\n", name);
01742 #endif
01743 
01744     /*
01745      * Fallback using the canonical names
01746      */
01747     alias = xmlParseCharEncoding(norig);
01748     if (alias != XML_CHAR_ENCODING_ERROR) {
01749         const char* canon;
01750         canon = xmlGetCharEncodingName(alias);
01751         if ((canon != NULL) && (strcmp(name, canon))) {
01752         return(xmlFindCharEncodingHandler(canon));
01753         }
01754     }
01755 
01756     /* If "none of the above", give up */
01757     return(NULL);
01758 }
01759 
01760 /************************************************************************
01761  *                                  *
01762  *      ICONV based generic conversion functions        *
01763  *                                  *
01764  ************************************************************************/
01765 
01766 #ifdef LIBXML_ICONV_ENABLED
01767 
01785 static int
01786 xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
01787                 const unsigned char *in, int *inlen) {
01788     size_t icv_inlen, icv_outlen;
01789     const char *icv_in = (const char *) in;
01790     char *icv_out = (char *) out;
01791     int ret;
01792 
01793     if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
01794         if (outlen != NULL) *outlen = 0;
01795         return(-1);
01796     }
01797     icv_inlen = *inlen;
01798     icv_outlen = *outlen;
01799     ret = iconv(cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
01800     *inlen -= icv_inlen;
01801     *outlen -= icv_outlen;
01802     if ((icv_inlen != 0) || (ret == -1)) {
01803 #ifdef EILSEQ
01804         if (errno == EILSEQ) {
01805             return -2;
01806         } else
01807 #endif
01808 #ifdef E2BIG
01809         if (errno == E2BIG) {
01810             return -1;
01811         } else
01812 #endif
01813 #ifdef EINVAL
01814         if (errno == EINVAL) {
01815             return -3;
01816         } else
01817 #endif
01818         {
01819             return -3;
01820         }
01821     }
01822     return 0;
01823 }
01824 #endif /* LIBXML_ICONV_ENABLED */
01825 
01826 /************************************************************************
01827  *                                  *
01828  *      ICU based generic conversion functions              *
01829  *                                  *
01830  ************************************************************************/
01831 
01832 #ifdef LIBXML_ICU_ENABLED
01833 
01852 static int
01853 xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
01854                 const unsigned char *in, int *inlen) {
01855     const char *ucv_in = (const char *) in;
01856     char *ucv_out = (char *) out;
01857     UErrorCode err = U_ZERO_ERROR;
01858 
01859     if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
01860         if (outlen != NULL) *outlen = 0;
01861         return(-1);
01862     }
01863 
01864     /*
01865      * TODO(jungshik)
01866      * 1. is ucnv_convert(To|From)Algorithmic better?
01867      * 2. had we better use an explicit pivot buffer?
01868      * 3. error returned comes from 'fromUnicode' only even
01869      *    when toUnicode is true !
01870      */
01871     if (toUnicode) {
01872         /* encoding => UTF-16 => UTF-8 */
01873         ucnv_convertEx(cd->utf8, cd->uconv, &ucv_out, ucv_out + *outlen,
01874                        &ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL,
01875                        0, TRUE, &err);
01876     } else {
01877         /* UTF-8 => UTF-16 => encoding */
01878         ucnv_convertEx(cd->uconv, cd->utf8, &ucv_out, ucv_out + *outlen,
01879                        &ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL,
01880                        0, TRUE, &err);
01881     }
01882     *inlen = ucv_in - (const char*) in;
01883     *outlen = ucv_out - (char *) out;
01884     if (U_SUCCESS(err))
01885         return 0;
01886     if (err == U_BUFFER_OVERFLOW_ERROR)
01887         return -1;
01888     if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND)
01889         return -2;
01890     /* if (err == U_TRUNCATED_CHAR_FOUND) */
01891     return -3;
01892 }
01893 #endif /* LIBXML_ICU_ENABLED */
01894 
01895 /************************************************************************
01896  *                                  *
01897  *      The real API used by libxml for on-the-fly conversion   *
01898  *                                  *
01899  ************************************************************************/
01900 int
01901 xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
01902                        xmlBufferPtr in, int len);
01903 
01919 int
01920 xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
01921                        xmlBufferPtr in, int len) {
01922     int ret = -2;
01923     int written;
01924     int toconv;
01925 
01926     if (handler == NULL) return(-1);
01927     if (out == NULL) return(-1);
01928     if (in == NULL) return(-1);
01929 
01930     /* calculate space available */
01931     written = out->size - out->use;
01932     toconv = in->use;
01933     /*
01934      * echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
01935      * 45 chars should be sufficient to reach the end of the encoding
01936      * declaration without going too far inside the document content.
01937      * on UTF-16 this means 90bytes, on UCS4 this means 180
01938      * The actual value depending on guessed encoding is passed as @len
01939      * if provided
01940      */
01941     if (len >= 0) {
01942         if (toconv > len)
01943             toconv = len;
01944     } else {
01945         if (toconv > 180)
01946             toconv = 180;
01947     }
01948     if (toconv * 2 >= written) {
01949         xmlBufferGrow(out, toconv);
01950     written = out->size - out->use - 1;
01951     }
01952 
01953     if (handler->input != NULL) {
01954     ret = handler->input(&out->content[out->use], &written,
01955                          in->content, &toconv);
01956     xmlBufferShrink(in, toconv);
01957     out->use += written;
01958     out->content[out->use] = 0;
01959     }
01960 #ifdef LIBXML_ICONV_ENABLED
01961     else if (handler->iconv_in != NULL) {
01962     ret = xmlIconvWrapper(handler->iconv_in, &out->content[out->use],
01963                           &written, in->content, &toconv);
01964     xmlBufferShrink(in, toconv);
01965     out->use += written;
01966     out->content[out->use] = 0;
01967     if (ret == -1) ret = -3;
01968     }
01969 #endif /* LIBXML_ICONV_ENABLED */
01970 #ifdef LIBXML_ICU_ENABLED
01971     else if (handler->uconv_in != NULL) {
01972     ret = xmlUconvWrapper(handler->uconv_in, 1, &out->content[out->use],
01973                           &written, in->content, &toconv);
01974     xmlBufferShrink(in, toconv);
01975     out->use += written;
01976     out->content[out->use] = 0;
01977     if (ret == -1) ret = -3;
01978     }
01979 #endif /* LIBXML_ICU_ENABLED */
01980 #ifdef DEBUG_ENCODING
01981     switch (ret) {
01982         case 0:
01983         xmlGenericError(xmlGenericErrorContext,
01984             "converted %d bytes to %d bytes of input\n",
01985                 toconv, written);
01986         break;
01987         case -1:
01988         xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
01989                 toconv, written, in->use);
01990         break;
01991         case -2:
01992         xmlGenericError(xmlGenericErrorContext,
01993             "input conversion failed due to input error\n");
01994         break;
01995         case -3:
01996         xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
01997                 toconv, written, in->use);
01998         break;
01999     default:
02000         xmlGenericError(xmlGenericErrorContext,"Unknown input conversion failed %d\n", ret);
02001     }
02002 #endif /* DEBUG_ENCODING */
02003     /*
02004      * Ignore when input buffer is not on a boundary
02005      */
02006     if (ret == -3) ret = 0;
02007     if (ret == -1) ret = 0;
02008     return(ret);
02009 }
02010 
02025 int
02026 xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
02027                  xmlBufferPtr in) {
02028     return(xmlCharEncFirstLineInt(handler, out, in, -1));
02029 }
02030 
02044 int
02045 xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
02046                  xmlBufferPtr in)
02047 {
02048     int ret = -2;
02049     int written;
02050     int toconv;
02051 
02052     if (handler == NULL)
02053         return (-1);
02054     if (out == NULL)
02055         return (-1);
02056     if (in == NULL)
02057         return (-1);
02058 
02059     toconv = in->use;
02060     if (toconv == 0)
02061         return (0);
02062     written = out->size - out->use;
02063     if (toconv * 2 >= written) {
02064         xmlBufferGrow(out, out->size + toconv * 2);
02065         written = out->size - out->use - 1;
02066     }
02067     if (handler->input != NULL) {
02068         ret = handler->input(&out->content[out->use], &written,
02069                              in->content, &toconv);
02070         xmlBufferShrink(in, toconv);
02071         out->use += written;
02072         out->content[out->use] = 0;
02073     }
02074 #ifdef LIBXML_ICONV_ENABLED
02075     else if (handler->iconv_in != NULL) {
02076         ret = xmlIconvWrapper(handler->iconv_in, &out->content[out->use],
02077                               &written, in->content, &toconv);
02078         xmlBufferShrink(in, toconv);
02079         out->use += written;
02080         out->content[out->use] = 0;
02081         if (ret == -1)
02082             ret = -3;
02083     }
02084 #endif /* LIBXML_ICONV_ENABLED */
02085 #ifdef LIBXML_ICU_ENABLED
02086     else if (handler->uconv_in != NULL) {
02087         ret = xmlUconvWrapper(handler->uconv_in, 1, &out->content[out->use],
02088                               &written, in->content, &toconv);
02089         xmlBufferShrink(in, toconv);
02090         out->use += written;
02091         out->content[out->use] = 0;
02092         if (ret == -1)
02093             ret = -3;
02094     }
02095 #endif /* LIBXML_ICU_ENABLED */
02096     switch (ret) {
02097         case 0:
02098 #ifdef DEBUG_ENCODING
02099             xmlGenericError(xmlGenericErrorContext,
02100                             "converted %d bytes to %d bytes of input\n",
02101                             toconv, written);
02102 #endif
02103             break;
02104         case -1:
02105 #ifdef DEBUG_ENCODING
02106             xmlGenericError(xmlGenericErrorContext,
02107                          "converted %d bytes to %d bytes of input, %d left\n",
02108                             toconv, written, in->use);
02109 #endif
02110             break;
02111         case -3:
02112 #ifdef DEBUG_ENCODING
02113             xmlGenericError(xmlGenericErrorContext,
02114                         "converted %d bytes to %d bytes of input, %d left\n",
02115                             toconv, written, in->use);
02116 #endif
02117             break;
02118         case -2: {
02119             char buf[50];
02120 
02121         snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
02122              in->content[0], in->content[1],
02123              in->content[2], in->content[3]);
02124         buf[49] = 0;
02125         xmlEncodingErr(XML_I18N_CONV_FAILED,
02126             "input conversion failed due to input error, bytes %s\n",
02127                    buf);
02128         }
02129     }
02130     /*
02131      * Ignore when input buffer is not on a boundary
02132      */
02133     if (ret == -3)
02134         ret = 0;
02135     return (written? written : ret);
02136 }
02137 
02156 int
02157 xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
02158                   xmlBufferPtr in) {
02159     int ret = -2;
02160     int written;
02161     int writtentot = 0;
02162     int toconv;
02163     int output = 0;
02164 
02165     if (handler == NULL) return(-1);
02166     if (out == NULL) return(-1);
02167 
02168 retry:
02169 
02170     written = out->size - out->use;
02171 
02172     if (written > 0)
02173     written--; /* Gennady: count '/0' */
02174 
02175     /*
02176      * First specific handling of in = NULL, i.e. the initialization call
02177      */
02178     if (in == NULL) {
02179         toconv = 0;
02180     if (handler->output != NULL) {
02181         ret = handler->output(&out->content[out->use], &written,
02182                   NULL, &toconv);
02183         if (ret >= 0) { /* Gennady: check return value */
02184         out->use += written;
02185         out->content[out->use] = 0;
02186         }
02187     }
02188 #ifdef LIBXML_ICONV_ENABLED
02189     else if (handler->iconv_out != NULL) {
02190         ret = xmlIconvWrapper(handler->iconv_out, &out->content[out->use],
02191                   &written, NULL, &toconv);
02192         out->use += written;
02193         out->content[out->use] = 0;
02194     }
02195 #endif /* LIBXML_ICONV_ENABLED */
02196 #ifdef LIBXML_ICU_ENABLED
02197     else if (handler->uconv_out != NULL) {
02198         ret = xmlUconvWrapper(handler->uconv_out, 0,
02199                               &out->content[out->use],
02200                               &written, NULL, &toconv);
02201         out->use += written;
02202         out->content[out->use] = 0;
02203     }
02204 #endif /* LIBXML_ICU_ENABLED */
02205 #ifdef DEBUG_ENCODING
02206     xmlGenericError(xmlGenericErrorContext,
02207         "initialized encoder\n");
02208 #endif
02209         return(0);
02210     }
02211 
02212     /*
02213      * Conversion itself.
02214      */
02215     toconv = in->use;
02216     if (toconv == 0)
02217     return(0);
02218     if (toconv * 4 >= written) {
02219         xmlBufferGrow(out, toconv * 4);
02220     written = out->size - out->use - 1;
02221     }
02222     if (handler->output != NULL) {
02223     ret = handler->output(&out->content[out->use], &written,
02224                           in->content, &toconv);
02225     if (written > 0) {
02226         xmlBufferShrink(in, toconv);
02227         out->use += written;
02228         writtentot += written;
02229     }
02230     out->content[out->use] = 0;
02231     }
02232 #ifdef LIBXML_ICONV_ENABLED
02233     else if (handler->iconv_out != NULL) {
02234     ret = xmlIconvWrapper(handler->iconv_out, &out->content[out->use],
02235                           &written, in->content, &toconv);
02236     xmlBufferShrink(in, toconv);
02237     out->use += written;
02238     writtentot += written;
02239     out->content[out->use] = 0;
02240     if (ret == -1) {
02241         if (written > 0) {
02242         /*
02243          * Can be a limitation of iconv
02244          */
02245         goto retry;
02246         }
02247         ret = -3;
02248     }
02249     }
02250 #endif /* LIBXML_ICONV_ENABLED */
02251 #ifdef LIBXML_ICU_ENABLED
02252     else if (handler->uconv_out != NULL) {
02253     ret = xmlUconvWrapper(handler->uconv_out, 0,
02254                               &out->content[out->use],
02255                           &written, in->content, &toconv);
02256     xmlBufferShrink(in, toconv);
02257     out->use += written;
02258     writtentot += written;
02259     out->content[out->use] = 0;
02260     if (ret == -1) {
02261         if (written > 0) {
02262         /*
02263          * Can be a limitation of iconv
02264          */
02265         goto retry;
02266         }
02267         ret = -3;
02268     }
02269     }
02270 #endif /* LIBXML_ICU_ENABLED */
02271     else {
02272     xmlEncodingErr(XML_I18N_NO_OUTPUT,
02273                "xmlCharEncOutFunc: no output function !\n", NULL);
02274     return(-1);
02275     }
02276 
02277     if (ret >= 0) output += ret;
02278 
02279     /*
02280      * Attempt to handle error cases
02281      */
02282     switch (ret) {
02283         case 0:
02284 #ifdef DEBUG_ENCODING
02285         xmlGenericError(xmlGenericErrorContext,
02286             "converted %d bytes to %d bytes of output\n",
02287                 toconv, written);
02288 #endif
02289         break;
02290         case -1:
02291 #ifdef DEBUG_ENCODING
02292         xmlGenericError(xmlGenericErrorContext,
02293             "output conversion failed by lack of space\n");
02294 #endif
02295         break;
02296         case -3:
02297 #ifdef DEBUG_ENCODING
02298         xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
02299                 toconv, written, in->use);
02300 #endif
02301         break;
02302         case -2: {
02303         int len = in->use;
02304         const xmlChar *utf = (const xmlChar *) in->content;
02305         int cur;
02306 
02307         cur = xmlGetUTF8Char(utf, &len);
02308         if (cur > 0) {
02309         xmlChar charref[20];
02310 
02311 #ifdef DEBUG_ENCODING
02312         xmlGenericError(xmlGenericErrorContext,
02313             "handling output conversion error\n");
02314         xmlGenericError(xmlGenericErrorContext,
02315             "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
02316             in->content[0], in->content[1],
02317             in->content[2], in->content[3]);
02318 #endif
02319         /*
02320          * Removes the UTF8 sequence, and replace it by a charref
02321          * and continue the transcoding phase, hoping the error
02322          * did not mangle the encoder state.
02323          */
02324         snprintf((char *) &charref[0], sizeof(charref), "&#%d;", cur);
02325         xmlBufferShrink(in, len);
02326         xmlBufferAddHead(in, charref, -1);
02327 
02328         goto retry;
02329         } else {
02330         char buf[50];
02331 
02332         snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
02333              in->content[0], in->content[1],
02334              in->content[2], in->content[3]);
02335         buf[49] = 0;
02336         xmlEncodingErr(XML_I18N_CONV_FAILED,
02337             "output conversion failed due to conv error, bytes %s\n",
02338                    buf);
02339         if (in->alloc != XML_BUFFER_ALLOC_IMMUTABLE)
02340             in->content[0] = ' ';
02341         }
02342         break;
02343     }
02344     }
02345     return(ret);
02346 }
02347 
02356 int
02357 xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
02358     int ret = 0;
02359     int tofree = 0;
02360     if (handler == NULL) return(-1);
02361     if (handler->name == NULL) return(-1);
02362 #ifdef LIBXML_ICONV_ENABLED
02363     /*
02364      * Iconv handlers can be used only once, free the whole block.
02365      * and the associated icon resources.
02366      */
02367     if ((handler->iconv_out != NULL) || (handler->iconv_in != NULL)) {
02368         tofree = 1;
02369     if (handler->iconv_out != NULL) {
02370         if (iconv_close(handler->iconv_out))
02371         ret = -1;
02372         handler->iconv_out = NULL;
02373     }
02374     if (handler->iconv_in != NULL) {
02375         if (iconv_close(handler->iconv_in))
02376         ret = -1;
02377         handler->iconv_in = NULL;
02378     }
02379     }
02380 #endif /* LIBXML_ICONV_ENABLED */
02381 #ifdef LIBXML_ICU_ENABLED
02382     if ((handler->uconv_out != NULL) || (handler->uconv_in != NULL)) {
02383         tofree = 1;
02384     if (handler->uconv_out != NULL) {
02385         closeIcuConverter(handler->uconv_out);
02386         handler->uconv_out = NULL;
02387     }
02388     if (handler->uconv_in != NULL) {
02389         closeIcuConverter(handler->uconv_in);
02390         handler->uconv_in = NULL;
02391     }
02392     }
02393 #endif
02394     if (tofree) {
02395         /* free up only dynamic handlers iconv/uconv */
02396         if (handler->name != NULL)
02397             xmlFree(handler->name);
02398         handler->name = NULL;
02399         xmlFree(handler);
02400     }
02401 #ifdef DEBUG_ENCODING
02402     if (ret)
02403         xmlGenericError(xmlGenericErrorContext,
02404         "failed to close the encoding handler\n");
02405     else
02406         xmlGenericError(xmlGenericErrorContext,
02407         "closed the encoding handler\n");
02408 #endif
02409 
02410     return(ret);
02411 }
02412 
02427 long
02428 xmlByteConsumed(xmlParserCtxtPtr ctxt) {
02429     xmlParserInputPtr in;
02430 
02431     if (ctxt == NULL) return(-1);
02432     in = ctxt->input;
02433     if (in == NULL)  return(-1);
02434     if ((in->buf != NULL) && (in->buf->encoder != NULL)) {
02435         unsigned int unused = 0;
02436     xmlCharEncodingHandler * handler = in->buf->encoder;
02437         /*
02438      * Encoding conversion, compute the number of unused original
02439      * bytes from the input not consumed and substract that from
02440      * the raw consumed value, this is not a cheap operation
02441      */
02442         if (in->end - in->cur > 0) {
02443         unsigned char convbuf[32000];
02444         const unsigned char *cur = (const unsigned char *)in->cur;
02445         int toconv = in->end - in->cur, written = 32000;
02446 
02447         int ret;
02448 
02449         if (handler->output != NULL) {
02450             do {
02451             toconv = in->end - cur;
02452             written = 32000;
02453             ret = handler->output(&convbuf[0], &written,
02454                       cur, &toconv);
02455             if (ret == -1) return(-1);
02456             unused += written;
02457             cur += toconv;
02458         } while (ret == -2);
02459 #ifdef LIBXML_ICONV_ENABLED
02460         } else if (handler->iconv_out != NULL) {
02461             do {
02462             toconv = in->end - cur;
02463             written = 32000;
02464             ret = xmlIconvWrapper(handler->iconv_out, &convbuf[0],
02465                           &written, cur, &toconv);
02466             if (ret < 0) {
02467                 if (written > 0)
02468                 ret = -2;
02469             else
02470                 return(-1);
02471             }
02472             unused += written;
02473             cur += toconv;
02474         } while (ret == -2);
02475 #endif
02476 #ifdef LIBXML_ICU_ENABLED
02477         } else if (handler->uconv_out != NULL) {
02478             do {
02479             toconv = in->end - cur;
02480             written = 32000;
02481             ret = xmlUconvWrapper(handler->uconv_out, 0, &convbuf[0],
02482                           &written, cur, &toconv);
02483             if (ret < 0) {
02484                 if (written > 0)
02485                 ret = -2;
02486             else
02487                 return(-1);
02488             }
02489             unused += written;
02490             cur += toconv;
02491         } while (ret == -2);
02492 #endif
02493             } else {
02494             /* could not find a converter */
02495             return(-1);
02496         }
02497     }
02498     if (in->buf->rawconsumed < unused)
02499         return(-1);
02500     return(in->buf->rawconsumed - unused);
02501     }
02502     return(in->consumed + (in->cur - in->base));
02503 }
02504 
02505 #if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
02506 #ifdef LIBXML_ISO8859X_ENABLED
02507 
02524 static int
02525 UTF8ToISO8859x(unsigned char* out, int *outlen,
02526               const unsigned char* in, int *inlen,
02527               unsigned char const *xlattable) {
02528     const unsigned char* outstart = out;
02529     const unsigned char* inend;
02530     const unsigned char* instart = in;
02531     const unsigned char* processed = in;
02532 
02533     if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
02534         (xlattable == NULL))
02535     return(-1);
02536     if (in == NULL) {
02537         /*
02538         * initialization nothing to do
02539         */
02540         *outlen = 0;
02541         *inlen = 0;
02542         return(0);
02543     }
02544     inend = in + (*inlen);
02545     while (in < inend) {
02546         unsigned char d = *in++;
02547         if  (d < 0x80)  {
02548             *out++ = d;
02549         } else if (d < 0xC0) {
02550             /* trailing byte in leading position */
02551             *outlen = out - outstart;
02552             *inlen = processed - instart;
02553             return(-2);
02554         } else if (d < 0xE0) {
02555             unsigned char c;
02556             if (!(in < inend)) {
02557                 /* trailing byte not in input buffer */
02558                 *outlen = out - outstart;
02559                 *inlen = processed - instart;
02560                 return(-3);
02561             }
02562             c = *in++;
02563             if ((c & 0xC0) != 0x80) {
02564                 /* not a trailing byte */
02565                 *outlen = out - outstart;
02566                 *inlen = processed - instart;
02567                 return(-2);
02568             }
02569             c = c & 0x3F;
02570             d = d & 0x1F;
02571             d = xlattable [48 + c + xlattable [d] * 64];
02572             if (d == 0) {
02573                 /* not in character set */
02574                 *outlen = out - outstart;
02575                 *inlen = processed - instart;
02576                 return(-2);
02577             }
02578             *out++ = d;
02579         } else if (d < 0xF0) {
02580             unsigned char c1;
02581             unsigned char c2;
02582             if (!(in < inend - 1)) {
02583                 /* trailing bytes not in input buffer */
02584                 *outlen = out - outstart;
02585                 *inlen = processed - instart;
02586                 return(-3);
02587             }
02588             c1 = *in++;
02589             if ((c1 & 0xC0) != 0x80) {
02590                 /* not a trailing byte (c1) */
02591                 *outlen = out - outstart;
02592                 *inlen = processed - instart;
02593                 return(-2);
02594             }
02595             c2 = *in++;
02596             if ((c2 & 0xC0) != 0x80) {
02597                 /* not a trailing byte (c2) */
02598                 *outlen = out - outstart;
02599                 *inlen = processed - instart;
02600                 return(-2);
02601             }
02602             c1 = c1 & 0x3F;
02603             c2 = c2 & 0x3F;
02604         d = d & 0x0F;
02605         d = xlattable [48 + c2 + xlattable [48 + c1 +
02606                 xlattable [32 + d] * 64] * 64];
02607             if (d == 0) {
02608                 /* not in character set */
02609                 *outlen = out - outstart;
02610                 *inlen = processed - instart;
02611                 return(-2);
02612             }
02613             *out++ = d;
02614         } else {
02615             /* cannot transcode >= U+010000 */
02616             *outlen = out - outstart;
02617             *inlen = processed - instart;
02618             return(-2);
02619         }
02620         processed = in;
02621     }
02622     *outlen = out - outstart;
02623     *inlen = processed - instart;
02624     return(*outlen);
02625 }
02626 
02640 static int
02641 ISO8859xToUTF8(unsigned char* out, int *outlen,
02642               const unsigned char* in, int *inlen,
02643               unsigned short const *unicodetable) {
02644     unsigned char* outstart = out;
02645     unsigned char* outend;
02646     const unsigned char* instart = in;
02647     const unsigned char* inend;
02648     const unsigned char* instop;
02649     unsigned int c;
02650 
02651     if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
02652         (in == NULL) || (unicodetable == NULL))
02653     return(-1);
02654     outend = out + *outlen;
02655     inend = in + *inlen;
02656     instop = inend;
02657 
02658     while ((in < inend) && (out < outend - 2)) {
02659         if (*in >= 0x80) {
02660             c = unicodetable [*in - 0x80];
02661             if (c == 0) {
02662                 /* undefined code point */
02663                 *outlen = out - outstart;
02664                 *inlen = in - instart;
02665                 return (-1);
02666             }
02667             if (c < 0x800) {
02668                 *out++ = ((c >>  6) & 0x1F) | 0xC0;
02669                 *out++ = (c & 0x3F) | 0x80;
02670             } else {
02671                 *out++ = ((c >>  12) & 0x0F) | 0xE0;
02672                 *out++ = ((c >>  6) & 0x3F) | 0x80;
02673                 *out++ = (c & 0x3F) | 0x80;
02674             }
02675             ++in;
02676         }
02677         if (instop - in > outend - out) instop = in + (outend - out);
02678         while ((*in < 0x80) && (in < instop)) {
02679             *out++ = *in++;
02680         }
02681     }
02682     if ((in < inend) && (out < outend) && (*in < 0x80)) {
02683         *out++ =  *in++;
02684     }
02685     if ((in < inend) && (out < outend) && (*in < 0x80)) {
02686         *out++ =  *in++;
02687     }
02688     *outlen = out - outstart;
02689     *inlen = in - instart;
02690     return (*outlen);
02691 }
02692 
02693 
02694 /************************************************************************
02695  * Lookup tables for ISO-8859-2..ISO-8859-16 transcoding                *
02696  ************************************************************************/
02697 
02698 static unsigned short const xmlunicodetable_ISO8859_2 [128] = {
02699     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
02700     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
02701     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
02702     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
02703     0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7,
02704     0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
02705     0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7,
02706     0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
02707     0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7,
02708     0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
02709     0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7,
02710     0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
02711     0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7,
02712     0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
02713     0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7,
02714     0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
02715 };
02716 
02717 static unsigned char const xmltranscodetable_ISO8859_2 [48 + 6 * 64] = {
02718     "\x00\x00\x01\x05\x02\x04\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00"
02719     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02720     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02721     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02722     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02723     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02724     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02725     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
02726     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
02727     "\xa0\x00\x00\x00\xa4\x00\x00\xa7\xa8\x00\x00\x00\x00\xad\x00\x00"
02728     "\xb0\x00\x00\x00\xb4\x00\x00\x00\xb8\x00\x00\x00\x00\x00\x00\x00"
02729     "\x00\x00\xc3\xe3\xa1\xb1\xc6\xe6\x00\x00\x00\x00\xc8\xe8\xcf\xef"
02730     "\xd0\xf0\x00\x00\x00\x00\x00\x00\xca\xea\xcc\xec\x00\x00\x00\x00"
02731     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02732     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc5\xe5\x00\x00\xa5\xb5\x00"
02733     "\x00\x00\x00\x00\x00\x00\x00\xb7\x00\x00\x00\x00\x00\x00\x00\x00"
02734     "\x00\x00\x00\x00\x00\x00\x00\x00\xa2\xff\x00\xb2\x00\xbd\x00\x00"
02735     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02736     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02737     "\x00\xa3\xb3\xd1\xf1\x00\x00\xd2\xf2\x00\x00\x00\x00\x00\x00\x00"
02738     "\xd5\xf5\x00\x00\xc0\xe0\x00\x00\xd8\xf8\xa6\xb6\x00\x00\xaa\xba"
02739     "\xa9\xb9\xde\xfe\xab\xbb\x00\x00\x00\x00\x00\x00\x00\x00\xd9\xf9"
02740     "\xdb\xfb\x00\x00\x00\x00\x00\x00\x00\xac\xbc\xaf\xbf\xae\xbe\x00"
02741     "\x00\xc1\xc2\x00\xc4\x00\x00\xc7\x00\xc9\x00\xcb\x00\xcd\xce\x00"
02742     "\x00\x00\x00\xd3\xd4\x00\xd6\xd7\x00\x00\xda\x00\xdc\xdd\x00\xdf"
02743     "\x00\xe1\xe2\x00\xe4\x00\x00\xe7\x00\xe9\x00\xeb\x00\xed\xee\x00"
02744     "\x00\x00\x00\xf3\xf4\x00\xf6\xf7\x00\x00\xfa\x00\xfc\xfd\x00\x00"
02745 };
02746 
02747 static unsigned short const xmlunicodetable_ISO8859_3 [128] = {
02748     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
02749     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
02750     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
02751     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
02752     0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7,
02753     0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b,
02754     0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7,
02755     0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c,
02756     0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7,
02757     0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
02758     0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7,
02759     0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df,
02760     0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7,
02761     0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
02762     0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7,
02763     0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9,
02764 };
02765 
02766 static unsigned char const xmltranscodetable_ISO8859_3 [48 + 7 * 64] = {
02767     "\x04\x00\x01\x06\x02\x05\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00"
02768     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02769     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02770     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02771     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02772     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02773     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02774     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
02775     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
02776     "\xa0\x00\x00\xa3\xa4\x00\x00\xa7\xa8\x00\x00\x00\x00\xad\x00\x00"
02777     "\xb0\x00\xb2\xb3\xb4\xb5\x00\xb7\xb8\x00\x00\x00\x00\xbd\x00\x00"
02778     "\x00\x00\x00\x00\x00\x00\x00\x00\xc6\xe6\xc5\xe5\x00\x00\x00\x00"
02779     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd8\xf8\xab\xbb"
02780     "\xd5\xf5\x00\x00\xa6\xb6\xa1\xb1\x00\x00\x00\x00\x00\x00\x00\x00"
02781     "\xa9\xb9\x00\x00\xac\xbc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02782     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02783     "\x00\x00\x00\x00\x00\x00\x00\x00\xa2\xff\x00\x00\x00\x00\x00\x00"
02784     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02785     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02786     "\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02787     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02788     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02789     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02790     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02791     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xfe\xaa\xba"
02792     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdd\xfd\x00\x00"
02793     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaf\xbf\x00\x00\x00"
02794     "\xc0\xc1\xc2\x00\xc4\x00\x00\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
02795     "\x00\xd1\xd2\xd3\xd4\x00\xd6\xd7\x00\xd9\xda\xdb\xdc\x00\x00\xdf"
02796     "\xe0\xe1\xe2\x00\xe4\x00\x00\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
02797     "\x00\xf1\xf2\xf3\xf4\x00\xf6\xf7\x00\xf9\xfa\xfb\xfc\x00\x00\x00"
02798 };
02799 
02800 static unsigned short const xmlunicodetable_ISO8859_4 [128] = {
02801     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
02802     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
02803     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
02804     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
02805     0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7,
02806     0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af,
02807     0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7,
02808     0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b,
02809     0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
02810     0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a,
02811     0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
02812     0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df,
02813     0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
02814     0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b,
02815     0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
02816     0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9,
02817 };
02818 
02819 static unsigned char const xmltranscodetable_ISO8859_4 [48 + 6 * 64] = {
02820     "\x00\x00\x01\x05\x02\x03\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00"
02821     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02822     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02823     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02824     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02825     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02826     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02827     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
02828     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
02829     "\xa0\x00\x00\x00\xa4\x00\x00\xa7\xa8\x00\x00\x00\x00\xad\x00\xaf"
02830     "\xb0\x00\x00\x00\xb4\x00\x00\x00\xb8\x00\x00\x00\x00\x00\x00\x00"
02831     "\xc0\xe0\x00\x00\xa1\xb1\x00\x00\x00\x00\x00\x00\xc8\xe8\x00\x00"
02832     "\xd0\xf0\xaa\xba\x00\x00\xcc\xec\xca\xea\x00\x00\x00\x00\x00\x00"
02833     "\x00\x00\xab\xbb\x00\x00\x00\x00\xa5\xb5\xcf\xef\x00\x00\xc7\xe7"
02834     "\x00\x00\x00\x00\x00\x00\xd3\xf3\xa2\x00\x00\xa6\xb6\x00\x00\x00"
02835     "\x00\x00\x00\x00\x00\xd1\xf1\x00\x00\x00\xbd\xbf\xd2\xf2\x00\x00"
02836     "\x00\x00\x00\x00\x00\x00\xa3\xb3\x00\x00\x00\x00\x00\x00\x00\x00"
02837     "\xa9\xb9\x00\x00\x00\x00\xac\xbc\xdd\xfd\xde\xfe\x00\x00\x00\x00"
02838     "\x00\x00\xd9\xf9\x00\x00\x00\x00\x00\x00\x00\x00\x00\xae\xbe\x00"
02839     "\x00\x00\x00\x00\x00\x00\x00\xb7\x00\x00\x00\x00\x00\x00\x00\x00"
02840     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\xb2\x00\x00\x00\x00"
02841     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02842     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02843     "\x00\xc1\xc2\xc3\xc4\xc5\xc6\x00\x00\xc9\x00\xcb\x00\xcd\xce\x00"
02844     "\x00\x00\x00\x00\xd4\xd5\xd6\xd7\xd8\x00\xda\xdb\xdc\x00\x00\xdf"
02845     "\x00\xe1\xe2\xe3\xe4\xe5\xe6\x00\x00\xe9\x00\xeb\x00\xed\xee\x00"
02846     "\x00\x00\x00\x00\xf4\xf5\xf6\xf7\xf8\x00\xfa\xfb\xfc\x00\x00\x00"
02847 };
02848 
02849 static unsigned short const xmlunicodetable_ISO8859_5 [128] = {
02850     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
02851     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
02852     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
02853     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
02854     0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
02855     0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f,
02856     0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
02857     0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
02858     0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
02859     0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
02860     0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
02861     0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
02862     0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
02863     0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
02864     0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
02865     0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f,
02866 };
02867 
02868 static unsigned char const xmltranscodetable_ISO8859_5 [48 + 6 * 64] = {
02869     "\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02870     "\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02871     "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02872     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02873     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02874     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02875     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02876     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
02877     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
02878     "\xa0\x00\x00\x00\x00\x00\x00\xfd\x00\x00\x00\x00\x00\xad\x00\x00"
02879     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02880     "\x00\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\x00\xae\xaf"
02881     "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
02882     "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
02883     "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
02884     "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
02885     "\x00\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\x00\xfe\xff"
02886     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02887     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02888     "\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02889     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02890     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02891     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02892     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02893     "\x00\x00\x00\x00\x00\x00\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02894     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02895     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02896 };
02897 
02898 static unsigned short const xmlunicodetable_ISO8859_6 [128] = {
02899     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
02900     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
02901     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
02902     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
02903     0x00a0, 0x0000, 0x0000, 0x0000, 0x00a4, 0x0000, 0x0000, 0x0000,
02904     0x0000, 0x0000, 0x0000, 0x0000, 0x060c, 0x00ad, 0x0000, 0x0000,
02905     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
02906     0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f,
02907     0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
02908     0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
02909     0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
02910     0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
02911     0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
02912     0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
02913     0x0650, 0x0651, 0x0652, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
02914     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
02915 };
02916 
02917 static unsigned char const xmltranscodetable_ISO8859_6 [48 + 5 * 64] = {
02918     "\x02\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02919     "\x00\x00\x00\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00"
02920     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02921     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02922     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02923     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02924     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02925     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
02926     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
02927     "\xa0\x00\x00\x00\xa4\x00\x00\x00\x00\x00\x00\x00\x00\xad\x00\x00"
02928     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02929     "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02930     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02931     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02932     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02933     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xac\x00\x00\x00"
02934     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbb\x00\x00\x00\xbf"
02935     "\x00\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
02936     "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\x00\x00\x00\x00\x00"
02937     "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
02938     "\xf0\xf1\xf2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02939     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02940     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02941 };
02942 
02943 static unsigned short const xmlunicodetable_ISO8859_7 [128] = {
02944     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
02945     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
02946     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
02947     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
02948     0x00a0, 0x2018, 0x2019, 0x00a3, 0x0000, 0x0000, 0x00a6, 0x00a7,
02949     0x00a8, 0x00a9, 0x0000, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015,
02950     0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7,
02951     0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f,
02952     0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
02953     0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
02954     0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
02955     0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
02956     0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
02957     0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
02958     0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
02959     0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000,
02960 };
02961 
02962 static unsigned char const xmltranscodetable_ISO8859_7 [48 + 7 * 64] = {
02963     "\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x06"
02964     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02965     "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02966     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02967     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02968     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02969     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02970     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
02971     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
02972     "\xa0\x00\x00\xa3\x00\x00\xa6\xa7\xa8\xa9\x00\xab\xac\xad\x00\x00"
02973     "\xb0\xb1\xb2\xb3\x00\x00\x00\xb7\x00\x00\x00\xbb\x00\xbd\x00\x00"
02974     "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02975     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02976     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02977     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02978     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02979     "\x00\x00\x00\x00\x00\xaf\x00\x00\xa1\xa2\x00\x00\x00\x00\x00\x00"
02980     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02981     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02982     "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02983     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02984     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02985     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02986     "\x00\x00\x00\x00\xb4\xb5\xb6\x00\xb8\xb9\xba\x00\xbc\x00\xbe\xbf"
02987     "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
02988     "\xd0\xd1\x00\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
02989     "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
02990     "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\x00"
02991     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02992     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02993     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
02994 };
02995 
02996 static unsigned short const xmlunicodetable_ISO8859_8 [128] = {
02997     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
02998     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
02999     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
03000     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
03001     0x00a0, 0x0000, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
03002     0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
03003     0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
03004     0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x0000,
03005     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
03006     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
03007     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
03008     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2017,
03009     0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
03010     0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
03011     0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
03012     0x05e8, 0x05e9, 0x05ea, 0x0000, 0x0000, 0x200e, 0x200f, 0x0000,
03013 };
03014 
03015 static unsigned char const xmltranscodetable_ISO8859_8 [48 + 7 * 64] = {
03016     "\x02\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03017     "\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00"
03018     "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03019     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03020     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03021     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03022     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03023     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
03024     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
03025     "\xa0\x00\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\x00\xab\xac\xad\xae\xaf"
03026     "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\x00\xbb\xbc\xbd\xbe\x00"
03027     "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03028     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03029     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03030     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03031     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03032     "\x00\x00\x00\x00\x00\x00\x00\xaa\x00\x00\x00\x00\x00\x00\x00\x00"
03033     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03034     "\x00\x00\x00\x00\x00\x00\x00\xba\x00\x00\x00\x00\x00\x00\x00\x00"
03035     "\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03036     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03037     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03038     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03039     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfd\xfe"
03040     "\x00\x00\x00\x00\x00\x00\x00\xdf\x00\x00\x00\x00\x00\x00\x00\x00"
03041     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03042     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03043     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03044     "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
03045     "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\x00\x00\x00\x00\x00"
03046     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03047 };
03048 
03049 static unsigned short const xmlunicodetable_ISO8859_9 [128] = {
03050     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
03051     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
03052     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
03053     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
03054     0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
03055     0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
03056     0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
03057     0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
03058     0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
03059     0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
03060     0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
03061     0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
03062     0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
03063     0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
03064     0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
03065     0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
03066 };
03067 
03068 static unsigned char const xmltranscodetable_ISO8859_9 [48 + 5 * 64] = {
03069     "\x00\x00\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03070     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03071     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03072     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03073     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03074     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03075     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03076     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
03077     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
03078     "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
03079     "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
03080     "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
03081     "\x00\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\x00\x00\xdf"
03082     "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
03083     "\x00\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\x00\x00\xff"
03084     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03085     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\xf0"
03086     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03087     "\xdd\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03088     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03089     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xfe"
03090     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03091     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03092 };
03093 
03094 static unsigned short const xmlunicodetable_ISO8859_10 [128] = {
03095     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
03096     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
03097     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
03098     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
03099     0x00a0, 0x0104, 0x0112, 0x0122, 0x012a, 0x0128, 0x0136, 0x00a7,
03100     0x013b, 0x0110, 0x0160, 0x0166, 0x017d, 0x00ad, 0x016a, 0x014a,
03101     0x00b0, 0x0105, 0x0113, 0x0123, 0x012b, 0x0129, 0x0137, 0x00b7,
03102     0x013c, 0x0111, 0x0161, 0x0167, 0x017e, 0x2015, 0x016b, 0x014b,
03103     0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
03104     0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x00cf,
03105     0x00d0, 0x0145, 0x014c, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0168,
03106     0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
03107     0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
03108     0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x00ef,
03109     0x00f0, 0x0146, 0x014d, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0169,
03110     0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138,
03111 };
03112 
03113 static unsigned char const xmltranscodetable_ISO8859_10 [48 + 7 * 64] = {
03114     "\x00\x00\x01\x06\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03115     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03116     "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03117     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03118     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03119     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03120     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03121     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
03122     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
03123     "\xa0\x00\x00\x00\x00\x00\x00\xa7\x00\x00\x00\x00\x00\xad\x00\x00"
03124     "\xb0\x00\x00\x00\x00\x00\x00\xb7\x00\x00\x00\x00\x00\x00\x00\x00"
03125     "\xc0\xe0\x00\x00\xa1\xb1\x00\x00\x00\x00\x00\x00\xc8\xe8\x00\x00"
03126     "\xa9\xb9\xa2\xb2\x00\x00\xcc\xec\xca\xea\x00\x00\x00\x00\x00\x00"
03127     "\x00\x00\xa3\xb3\x00\x00\x00\x00\xa5\xb5\xa4\xb4\x00\x00\xc7\xe7"
03128     "\x00\x00\x00\x00\x00\x00\xa6\xb6\xff\x00\x00\xa8\xb8\x00\x00\x00"
03129     "\x00\x00\x00\x00\x00\xd1\xf1\x00\x00\x00\xaf\xbf\xd2\xf2\x00\x00"
03130     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03131     "\xaa\xba\x00\x00\x00\x00\xab\xbb\xd7\xf7\xae\xbe\x00\x00\x00\x00"
03132     "\x00\x00\xd9\xf9\x00\x00\x00\x00\x00\x00\x00\x00\x00\xac\xbc\x00"
03133     "\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03134     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03135     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03136     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03137     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03138     "\x00\x00\x00\x00\x00\xbd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03139     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03140     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03141     "\x00\xc1\xc2\xc3\xc4\xc5\xc6\x00\x00\xc9\x00\xcb\x00\xcd\xce\xcf"
03142     "\xd0\x00\x00\xd3\xd4\xd5\xd6\x00\xd8\x00\xda\xdb\xdc\xdd\xde\xdf"
03143     "\x00\xe1\xe2\xe3\xe4\xe5\xe6\x00\x00\xe9\x00\xeb\x00\xed\xee\xef"
03144     "\xf0\x00\x00\xf3\xf4\xf5\xf6\x00\xf8\x00\xfa\xfb\xfc\xfd\xfe\x00"
03145 };
03146 
03147 static unsigned short const xmlunicodetable_ISO8859_11 [128] = {
03148     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
03149     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
03150     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
03151     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
03152     0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
03153     0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
03154     0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
03155     0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
03156     0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
03157     0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
03158     0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
03159     0x0e38, 0x0e39, 0x0e3a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0e3f,
03160     0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
03161     0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
03162     0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
03163     0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x0000, 0x0000, 0x0000, 0x0000,
03164 };
03165 
03166 static unsigned char const xmltranscodetable_ISO8859_11 [48 + 6 * 64] = {
03167     "\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03168     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03169     "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03170     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03171     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03172     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03173     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03174     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
03175     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
03176     "\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03177     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03178     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03179     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03180     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03181     "\x00\x00\x00\x00\x00\x00\x00\x00\x03\x05\x00\x00\x00\x00\x00\x00"
03182     "\x00\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
03183     "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
03184     "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
03185     "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\x00\x00\x00\x00\xdf"
03186     "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03187     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03188     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03189     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03190     "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
03191     "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\x00\x00\x00\x00"
03192     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03193     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03194 };
03195 
03196 static unsigned short const xmlunicodetable_ISO8859_13 [128] = {
03197     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
03198     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
03199     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
03200     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
03201     0x00a0, 0x201d, 0x00a2, 0x00a3, 0x00a4, 0x201e, 0x00a6, 0x00a7,
03202     0x00d8, 0x00a9, 0x0156, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00c6,
03203     0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x201c, 0x00b5, 0x00b6, 0x00b7,
03204     0x00f8, 0x00b9, 0x0157, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00e6,
03205     0x0104, 0x012e, 0x0100, 0x0106, 0x00c4, 0x00c5, 0x0118, 0x0112,
03206     0x010c, 0x00c9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012a, 0x013b,
03207     0x0160, 0x0143, 0x0145, 0x00d3, 0x014c, 0x00d5, 0x00d6, 0x00d7,
03208     0x0172, 0x0141, 0x015a, 0x016a, 0x00dc, 0x017b, 0x017d, 0x00df,
03209     0x0105, 0x012f, 0x0101, 0x0107, 0x00e4, 0x00e5, 0x0119, 0x0113,
03210     0x010d, 0x00e9, 0x017a, 0x0117, 0x0123, 0x0137, 0x012b, 0x013c,
03211     0x0161, 0x0144, 0x0146, 0x00f3, 0x014d, 0x00f5, 0x00f6, 0x00f7,
03212     0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019,
03213 };
03214 
03215 static unsigned char const xmltranscodetable_ISO8859_13 [48 + 7 * 64] = {
03216     "\x00\x00\x01\x04\x06\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03217     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03218     "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03219     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03220     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03221     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03222     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03223     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
03224     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
03225     "\xa0\x00\xa2\xa3\xa4\x00\xa6\xa7\x00\xa9\x00\xab\xac\xad\xae\x00"
03226     "\xb0\xb1\xb2\xb3\x00\xb5\xb6\xb7\x00\xb9\x00\xbb\xbc\xbd\xbe\x00"
03227     "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03228     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03229     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03230     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03231     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03232     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\xb4\xa1\xa5\x00"
03233     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03234     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03235     "\x00\x00\x00\x00\xc4\xc5\xaf\x00\x00\xc9\x00\x00\x00\x00\x00\x00"
03236     "\x00\x00\x00\xd3\x00\xd5\xd6\xd7\xa8\x00\x00\x00\xdc\x00\x00\xdf"
03237     "\x00\x00\x00\x00\xe4\xe5\xbf\x00\x00\xe9\x00\x00\x00\x00\x00\x00"
03238     "\x00\x00\x00\xf3\x00\xf5\xf6\xf7\xb8\x00\x00\x00\xfc\x00\x00\x00"
03239     "\x00\xd9\xf9\xd1\xf1\xd2\xf2\x00\x00\x00\x00\x00\xd4\xf4\x00\x00"
03240     "\x00\x00\x00\x00\x00\x00\xaa\xba\x00\x00\xda\xfa\x00\x00\x00\x00"
03241     "\xd0\xf0\x00\x00\x00\x00\x00\x00\x00\x00\xdb\xfb\x00\x00\x00\x00"
03242     "\x00\x00\xd8\xf8\x00\x00\x00\x00\x00\xca\xea\xdd\xfd\xde\xfe\x00"
03243     "\xc2\xe2\x00\x00\xc0\xe0\xc3\xe3\x00\x00\x00\x00\xc8\xe8\x00\x00"
03244     "\x00\x00\xc7\xe7\x00\x00\xcb\xeb\xc6\xe6\x00\x00\x00\x00\x00\x00"
03245     "\x00\x00\xcc\xec\x00\x00\x00\x00\x00\x00\xce\xee\x00\x00\xc1\xe1"
03246     "\x00\x00\x00\x00\x00\x00\xcd\xed\x00\x00\x00\xcf\xef\x00\x00\x00"
03247 };
03248 
03249 static unsigned short const xmlunicodetable_ISO8859_14 [128] = {
03250     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
03251     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
03252     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
03253     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
03254     0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7,
03255     0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178,
03256     0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56,
03257     0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61,
03258     0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
03259     0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
03260     0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a,
03261     0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df,
03262     0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
03263     0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
03264     0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b,
03265     0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff,
03266 };
03267 
03268 static unsigned char const xmltranscodetable_ISO8859_14 [48 + 10 * 64] = {
03269     "\x00\x00\x01\x09\x04\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03270     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03271     "\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03272     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03273     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03274     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03275     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03276     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
03277     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
03278     "\xa0\x00\x00\xa3\x00\x00\x00\xa7\x00\xa9\x00\x00\x00\xad\xae\x00"
03279     "\x00\x00\x00\x00\x00\x00\xb6\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03280     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03281     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03282     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03283     "\x00\x00\x00\x00\x00\x00\x00\x00\x03\x08\x05\x06\x00\x00\x00\x00"
03284     "\x00\x00\xa1\xa2\x00\x00\x00\x00\x00\x00\xa6\xab\x00\x00\x00\x00"
03285     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\xb1"
03286     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03287     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03288     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\xa5\x00\x00\x00\x00"
03289     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03290     "\xb2\xb3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03291     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03292     "\xa8\xb8\xaa\xba\xbd\xbe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03293     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03294     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03295     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03296     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03297     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03298     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03299     "\x00\x00\xac\xbc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03300     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03301     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03302     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03303     "\x00\x00\x00\x00\xd0\xf0\xde\xfe\xaf\x00\x00\x00\x00\x00\x00\x00"
03304     "\xb4\xb5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03305     "\x00\x00\x00\x00\x00\x00\xb7\xb9\x00\x00\x00\x00\x00\x00\x00\x00"
03306     "\xbb\xbf\x00\x00\x00\x00\x00\x00\x00\x00\xd7\xf7\x00\x00\x00\x00"
03307     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03308     "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
03309     "\x00\xd1\xd2\xd3\xd4\xd5\xd6\x00\xd8\xd9\xda\xdb\xdc\xdd\x00\xdf"
03310     "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
03311     "\x00\xf1\xf2\xf3\xf4\xf5\xf6\x00\xf8\xf9\xfa\xfb\xfc\xfd\x00\xff"
03312 };
03313 
03314 static unsigned short const xmlunicodetable_ISO8859_15 [128] = {
03315     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
03316     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
03317     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
03318     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
03319     0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7,
03320     0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
03321     0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7,
03322     0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
03323     0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
03324     0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
03325     0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
03326     0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
03327     0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
03328     0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
03329     0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
03330     0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
03331 };
03332 
03333 static unsigned char const xmltranscodetable_ISO8859_15 [48 + 6 * 64] = {
03334     "\x00\x00\x01\x05\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03335     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03336     "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03337     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03338     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03339     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03340     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03341     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
03342     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
03343     "\xa0\xa1\xa2\xa3\x00\xa5\x00\xa7\x00\xa9\xaa\xab\xac\xad\xae\xaf"
03344     "\xb0\xb1\xb2\xb3\x00\xb5\xb6\xb7\x00\xb9\xba\xbb\x00\x00\x00\xbf"
03345     "\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03346     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03347     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03348     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03349     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03350     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03351     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x00\x00\x00"
03352     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03353     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03354     "\x00\x00\xbc\xbd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03355     "\xa6\xa8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03356     "\x00\x00\x00\x00\x00\x00\x00\x00\xbe\x00\x00\x00\x00\xb4\xb8\x00"
03357     "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
03358     "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
03359     "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
03360     "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
03361 };
03362 
03363 static unsigned short const xmlunicodetable_ISO8859_16 [128] = {
03364     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
03365     0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
03366     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
03367     0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
03368     0x00a0, 0x0104, 0x0105, 0x0141, 0x20ac, 0x201e, 0x0160, 0x00a7,
03369     0x0161, 0x00a9, 0x0218, 0x00ab, 0x0179, 0x00ad, 0x017a, 0x017b,
03370     0x00b0, 0x00b1, 0x010c, 0x0142, 0x017d, 0x201d, 0x00b6, 0x00b7,
03371     0x017e, 0x010d, 0x0219, 0x00bb, 0x0152, 0x0153, 0x0178, 0x017c,
03372     0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0106, 0x00c6, 0x00c7,
03373     0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
03374     0x0110, 0x0143, 0x00d2, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x015a,
03375     0x0170, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0118, 0x021a, 0x00df,
03376     0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x0107, 0x00e6, 0x00e7,
03377     0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
03378     0x0111, 0x0144, 0x00f2, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x015b,
03379     0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff,
03380 };
03381 
03382 static unsigned char const xmltranscodetable_ISO8859_16 [48 + 9 * 64] = {
03383     "\x00\x00\x01\x08\x02\x03\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00"
03384     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03385     "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03386     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03387     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03388     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03389     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03390     "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
03391     "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
03392     "\xa0\x00\x00\x00\x00\x00\x00\xa7\x00\xa9\x00\xab\x00\xad\x00\x00"
03393     "\xb0\xb1\x00\x00\x00\x00\xb6\xb7\x00\x00\x00\xbb\x00\x00\x00\x00"
03394     "\x00\x00\xc3\xe3\xa1\xa2\xc5\xe5\x00\x00\x00\x00\xb2\xb9\x00\x00"
03395     "\xd0\xf0\x00\x00\x00\x00\x00\x00\xdd\xfd\x00\x00\x00\x00\x00\x00"
03396     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03397     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03398     "\x00\xa3\xb3\xd1\xf1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03399     "\xd5\xf5\xbc\xbd\x00\x00\x00\x00\x00\x00\xd7\xf7\x00\x00\x00\x00"
03400     "\xa6\xa8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03401     "\xd8\xf8\x00\x00\x00\x00\x00\x00\xbe\xac\xae\xaf\xbf\xb4\xb8\x00"
03402     "\x06\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03403     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03404     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03405     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03406     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03407     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03408     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x00\x00\x00"
03409     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03410     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03411     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb5\xa5\x00"
03412     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03413     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03414     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03415     "\x00\x00\x00\x00\x00\x00\x00\x00\xaa\xba\xde\xfe\x00\x00\x00\x00"
03416     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03417     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
03418     "\xc0\xc1\xc2\x00\xc4\x00\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
03419     "\x00\x00\xd2\xd3\xd4\x00\xd6\x00\x00\xd9\xda\xdb\xdc\x00\x00\xdf"
03420     "\xe0\xe1\xe2\x00\xe4\x00\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
03421     "\x00\x00\xf2\xf3\xf4\x00\xf6\x00\x00\xf9\xfa\xfb\xfc\x00\x00\xff"
03422 };
03423 
03424 
03425 /*
03426  * auto-generated functions for ISO-8859-2 .. ISO-8859-16
03427  */
03428 
03429 static int ISO8859_2ToUTF8 (unsigned char* out, int *outlen,
03430     const unsigned char* in, int *inlen) {
03431     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_2);
03432 }
03433 static int UTF8ToISO8859_2 (unsigned char* out, int *outlen,
03434     const unsigned char* in, int *inlen) {
03435     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_2);
03436 }
03437 
03438 static int ISO8859_3ToUTF8 (unsigned char* out, int *outlen,
03439     const unsigned char* in, int *inlen) {
03440     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_3);
03441 }
03442 static int UTF8ToISO8859_3 (unsigned char* out, int *outlen,
03443     const unsigned char* in, int *inlen) {
03444     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_3);
03445 }
03446 
03447 static int ISO8859_4ToUTF8 (unsigned char* out, int *outlen,
03448     const unsigned char* in, int *inlen) {
03449     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_4);
03450 }
03451 static int UTF8ToISO8859_4 (unsigned char* out, int *outlen,
03452     const unsigned char* in, int *inlen) {
03453     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_4);
03454 }
03455 
03456 static int ISO8859_5ToUTF8 (unsigned char* out, int *outlen,
03457     const unsigned char* in, int *inlen) {
03458     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_5);
03459 }
03460 static int UTF8ToISO8859_5 (unsigned char* out, int *outlen,
03461     const unsigned char* in, int *inlen) {
03462     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_5);
03463 }
03464 
03465 static int ISO8859_6ToUTF8 (unsigned char* out, int *outlen,
03466     const unsigned char* in, int *inlen) {
03467     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_6);
03468 }
03469 static int UTF8ToISO8859_6 (unsigned char* out, int *outlen,
03470     const unsigned char* in, int *inlen) {
03471     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_6);
03472 }
03473 
03474 static int ISO8859_7ToUTF8 (unsigned char* out, int *outlen,
03475     const unsigned char* in, int *inlen) {
03476     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_7);
03477 }
03478 static int UTF8ToISO8859_7 (unsigned char* out, int *outlen,
03479     const unsigned char* in, int *inlen) {
03480     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_7);
03481 }
03482 
03483 static int ISO8859_8ToUTF8 (unsigned char* out, int *outlen,
03484     const unsigned char* in, int *inlen) {
03485     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_8);
03486 }
03487 static int UTF8ToISO8859_8 (unsigned char* out, int *outlen,
03488     const unsigned char* in, int *inlen) {
03489     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_8);
03490 }
03491 
03492 static int ISO8859_9ToUTF8 (unsigned char* out, int *outlen,
03493     const unsigned char* in, int *inlen) {
03494     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_9);
03495 }
03496 static int UTF8ToISO8859_9 (unsigned char* out, int *outlen,
03497     const unsigned char* in, int *inlen) {
03498     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_9);
03499 }
03500 
03501 static int ISO8859_10ToUTF8 (unsigned char* out, int *outlen,
03502     const unsigned char* in, int *inlen) {
03503     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_10);
03504 }
03505 static int UTF8ToISO8859_10 (unsigned char* out, int *outlen,
03506     const unsigned char* in, int *inlen) {
03507     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_10);
03508 }
03509 
03510 static int ISO8859_11ToUTF8 (unsigned char* out, int *outlen,
03511     const unsigned char* in, int *inlen) {
03512     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_11);
03513 }
03514 static int UTF8ToISO8859_11 (unsigned char* out, int *outlen,
03515     const unsigned char* in, int *inlen) {
03516     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_11);
03517 }
03518 
03519 static int ISO8859_13ToUTF8 (unsigned char* out, int *outlen,
03520     const unsigned char* in, int *inlen) {
03521     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_13);
03522 }
03523 static int UTF8ToISO8859_13 (unsigned char* out, int *outlen,
03524     const unsigned char* in, int *inlen) {
03525     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_13);
03526 }
03527 
03528 static int ISO8859_14ToUTF8 (unsigned char* out, int *outlen,
03529     const unsigned char* in, int *inlen) {
03530     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_14);
03531 }
03532 static int UTF8ToISO8859_14 (unsigned char* out, int *outlen,
03533     const unsigned char* in, int *inlen) {
03534     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_14);
03535 }
03536 
03537 static int ISO8859_15ToUTF8 (unsigned char* out, int *outlen,
03538     const unsigned char* in, int *inlen) {
03539     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_15);
03540 }
03541 static int UTF8ToISO8859_15 (unsigned char* out, int *outlen,
03542     const unsigned char* in, int *inlen) {
03543     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_15);
03544 }
03545 
03546 static int ISO8859_16ToUTF8 (unsigned char* out, int *outlen,
03547     const unsigned char* in, int *inlen) {
03548     return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_16);
03549 }
03550 static int UTF8ToISO8859_16 (unsigned char* out, int *outlen,
03551     const unsigned char* in, int *inlen) {
03552     return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_16);
03553 }
03554 
03555 static void
03556 xmlRegisterCharEncodingHandlersISO8859x (void) {
03557     xmlNewCharEncodingHandler ("ISO-8859-2", ISO8859_2ToUTF8, UTF8ToISO8859_2);
03558     xmlNewCharEncodingHandler ("ISO-8859-3", ISO8859_3ToUTF8, UTF8ToISO8859_3);
03559     xmlNewCharEncodingHandler ("ISO-8859-4", ISO8859_4ToUTF8, UTF8ToISO8859_4);
03560     xmlNewCharEncodingHandler ("ISO-8859-5", ISO8859_5ToUTF8, UTF8ToISO8859_5);
03561     xmlNewCharEncodingHandler ("ISO-8859-6", ISO8859_6ToUTF8, UTF8ToISO8859_6);
03562     xmlNewCharEncodingHandler ("ISO-8859-7", ISO8859_7ToUTF8, UTF8ToISO8859_7);
03563     xmlNewCharEncodingHandler ("ISO-8859-8", ISO8859_8ToUTF8, UTF8ToISO8859_8);
03564     xmlNewCharEncodingHandler ("ISO-8859-9", ISO8859_9ToUTF8, UTF8ToISO8859_9);
03565     xmlNewCharEncodingHandler ("ISO-8859-10", ISO8859_10ToUTF8, UTF8ToISO8859_10);
03566     xmlNewCharEncodingHandler ("ISO-8859-11", ISO8859_11ToUTF8, UTF8ToISO8859_11);
03567     xmlNewCharEncodingHandler ("ISO-8859-13", ISO8859_13ToUTF8, UTF8ToISO8859_13);
03568     xmlNewCharEncodingHandler ("ISO-8859-14", ISO8859_14ToUTF8, UTF8ToISO8859_14);
03569     xmlNewCharEncodingHandler ("ISO-8859-15", ISO8859_15ToUTF8, UTF8ToISO8859_15);
03570     xmlNewCharEncodingHandler ("ISO-8859-16", ISO8859_16ToUTF8, UTF8ToISO8859_16);
03571 }
03572 
03573 #endif
03574 #endif
03575 
03576 #define bottom_encoding
03577 #include "elfgcchack.h"

Generated on Sat May 26 2012 04:33:17 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.