Blame encoding.c

Packit 423ecb
/*
Packit 423ecb
 * encoding.c : implements the encoding conversion functions needed for XML
Packit 423ecb
 *
Packit 423ecb
 * Related specs:
Packit 423ecb
 * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies
Packit 423ecb
 * rfc2781        UTF-16, an encoding of ISO 10646, P. Hoffman, F. Yergeau
Packit 423ecb
 * [ISO-10646]    UTF-8 and UTF-16 in Annexes
Packit 423ecb
 * [ISO-8859-1]   ISO Latin-1 characters codes.
Packit 423ecb
 * [UNICODE]      The Unicode Consortium, "The Unicode Standard --
Packit 423ecb
 *                Worldwide Character Encoding -- Version 1.0", Addison-
Packit 423ecb
 *                Wesley, Volume 1, 1991, Volume 2, 1992.  UTF-8 is
Packit 423ecb
 *                described in Unicode Technical Report #4.
Packit 423ecb
 * [US-ASCII]     Coded Character Set--7-bit American Standard Code for
Packit 423ecb
 *                Information Interchange, ANSI X3.4-1986.
Packit 423ecb
 *
Packit 423ecb
 * See Copyright for the status of this software.
Packit 423ecb
 *
Packit 423ecb
 * daniel@veillard.com
Packit 423ecb
 *
Packit 423ecb
 * Original code for IsoLatin1 and UTF-16 by "Martin J. Duerst" <duerst@w3.org>
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
#define IN_LIBXML
Packit 423ecb
#include "libxml.h"
Packit 423ecb
Packit 423ecb
#include <string.h>
Packit 423ecb
#include <limits.h>
Packit 423ecb
Packit 423ecb
#ifdef HAVE_CTYPE_H
Packit 423ecb
#include <ctype.h>
Packit 423ecb
#endif
Packit 423ecb
#ifdef HAVE_STDLIB_H
Packit 423ecb
#include <stdlib.h>
Packit 423ecb
#endif
Packit 423ecb
#ifdef LIBXML_ICONV_ENABLED
Packit 423ecb
#ifdef HAVE_ERRNO_H
Packit 423ecb
#include <errno.h>
Packit 423ecb
#endif
Packit 423ecb
#endif
Packit 423ecb
#include <libxml/encoding.h>
Packit 423ecb
#include <libxml/xmlmemory.h>
Packit 423ecb
#ifdef LIBXML_HTML_ENABLED
Packit 423ecb
#include <libxml/HTMLparser.h>
Packit 423ecb
#endif
Packit 423ecb
#include <libxml/globals.h>
Packit 423ecb
#include <libxml/xmlerror.h>
Packit 423ecb
Packit 423ecb
#include "buf.h"
Packit 423ecb
#include "enc.h"
Packit 423ecb
Packit 423ecb
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
Packit 423ecb
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
Packit 423ecb
Packit 423ecb
typedef struct _xmlCharEncodingAlias xmlCharEncodingAlias;
Packit 423ecb
typedef xmlCharEncodingAlias *xmlCharEncodingAliasPtr;
Packit 423ecb
struct _xmlCharEncodingAlias {
Packit 423ecb
    const char *name;
Packit 423ecb
    const char *alias;
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static xmlCharEncodingAliasPtr xmlCharEncodingAliases = NULL;
Packit 423ecb
static int xmlCharEncodingAliasesNb = 0;
Packit 423ecb
static int xmlCharEncodingAliasesMax = 0;
Packit 423ecb
Packit 423ecb
#if defined(LIBXML_ICONV_ENABLED) || defined(LIBXML_ICU_ENABLED)
Packit 423ecb
#if 0
Packit 423ecb
#define DEBUG_ENCODING  /* Define this to get encoding traces */
Packit 423ecb
#endif
Packit 423ecb
#else
Packit 423ecb
#ifdef LIBXML_ISO8859X_ENABLED
Packit 423ecb
static void xmlRegisterCharEncodingHandlersISO8859x (void);
Packit 423ecb
#endif
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
static int xmlLittleEndian = 1;
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlEncodingErrMemory:
Packit 423ecb
 * @extra:  extra informations
Packit 423ecb
 *
Packit 423ecb
 * Handle an out of memory condition
Packit 423ecb
 */
Packit 423ecb
static void
Packit 423ecb
xmlEncodingErrMemory(const char *extra)
Packit 423ecb
{
Packit 423ecb
    __xmlSimpleError(XML_FROM_I18N, XML_ERR_NO_MEMORY, NULL, NULL, extra);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlErrEncoding:
Packit 423ecb
 * @error:  the error number
Packit 423ecb
 * @msg:  the error message
Packit 423ecb
 *
Packit 423ecb
 * n encoding error
Packit 423ecb
 */
Packit 423ecb
static void LIBXML_ATTR_FORMAT(2,0)
Packit 423ecb
xmlEncodingErr(xmlParserErrors error, const char *msg, const char *val)
Packit 423ecb
{
Packit 423ecb
    __xmlRaiseError(NULL, NULL, NULL, NULL, NULL,
Packit 423ecb
                    XML_FROM_I18N, error, XML_ERR_FATAL,
Packit 423ecb
                    NULL, 0, val, NULL, NULL, 0, 0, msg, val);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_ICU_ENABLED
Packit 423ecb
static uconv_t*
Packit 423ecb
openIcuConverter(const char* name, int toUnicode)
Packit 423ecb
{
Packit 423ecb
  UErrorCode status = U_ZERO_ERROR;
Packit 423ecb
  uconv_t *conv = (uconv_t *) xmlMalloc(sizeof(uconv_t));
Packit 423ecb
  if (conv == NULL)
Packit 423ecb
    return NULL;
Packit 423ecb
Packit 423ecb
  conv->uconv = ucnv_open(name, &status);
Packit 423ecb
  if (U_FAILURE(status))
Packit 423ecb
    goto error;
Packit 423ecb
Packit 423ecb
  status = U_ZERO_ERROR;
Packit 423ecb
  if (toUnicode) {
Packit 423ecb
    ucnv_setToUCallBack(conv->uconv, UCNV_TO_U_CALLBACK_STOP,
Packit 423ecb
                        NULL, NULL, NULL, &status);
Packit 423ecb
  }
Packit 423ecb
  else {
Packit 423ecb
    ucnv_setFromUCallBack(conv->uconv, UCNV_FROM_U_CALLBACK_STOP,
Packit 423ecb
                        NULL, NULL, NULL, &status);
Packit 423ecb
  }
Packit 423ecb
  if (U_FAILURE(status))
Packit 423ecb
    goto error;
Packit 423ecb
Packit 423ecb
  status = U_ZERO_ERROR;
Packit 423ecb
  conv->utf8 = ucnv_open("UTF-8", &status);
Packit 423ecb
  if (U_SUCCESS(status))
Packit 423ecb
    return conv;
Packit 423ecb
Packit 423ecb
error:
Packit 423ecb
  if (conv->uconv)
Packit 423ecb
    ucnv_close(conv->uconv);
Packit 423ecb
  xmlFree(conv);
Packit 423ecb
  return NULL;
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static void
Packit 423ecb
closeIcuConverter(uconv_t *conv)
Packit 423ecb
{
Packit 423ecb
  if (conv != NULL) {
Packit 423ecb
    ucnv_close(conv->uconv);
Packit 423ecb
    ucnv_close(conv->utf8);
Packit 423ecb
    xmlFree(conv);
Packit 423ecb
  }
Packit 423ecb
}
Packit 423ecb
#endif /* LIBXML_ICU_ENABLED */
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *		Conversions To/From UTF8 encoding			*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * asciiToUTF8:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of ASCII chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Take a block of ASCII chars in and try to convert it to an UTF-8
Packit 423ecb
 * block of chars out.
Packit 423ecb
 * Returns 0 if success, or -1 otherwise
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 *     if the return value is positive, else unpredictable.
Packit 423ecb
 * The value of @outlen after return is the number of octets consumed.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
asciiToUTF8(unsigned char* out, int *outlen,
Packit 423ecb
              const unsigned char* in, int *inlen) {
Packit 423ecb
    unsigned char* outstart = out;
Packit 423ecb
    const unsigned char* base = in;
Packit 423ecb
    const unsigned char* processed = in;
Packit 423ecb
    unsigned char* outend = out + *outlen;
Packit 423ecb
    const unsigned char* inend;
Packit 423ecb
    unsigned int c;
Packit 423ecb
Packit 423ecb
    inend = in + (*inlen);
Packit 423ecb
    while ((in < inend) && (out - outstart + 5 < *outlen)) {
Packit 423ecb
	c= *in++;
Packit 423ecb
Packit 423ecb
        if (out >= outend)
Packit 423ecb
	    break;
Packit 423ecb
        if (c < 0x80) {
Packit 423ecb
	    *out++ = c;
Packit 423ecb
	} else {
Packit 423ecb
	    *outlen = out - outstart;
Packit 423ecb
	    *inlen = processed - base;
Packit 423ecb
	    return(-1);
Packit 423ecb
	}
Packit 423ecb
Packit 423ecb
	processed = (const unsigned char*) in;
Packit 423ecb
    }
Packit 423ecb
    *outlen = out - outstart;
Packit 423ecb
    *inlen = processed - base;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_OUTPUT_ENABLED
Packit 423ecb
/**
Packit 423ecb
 * UTF8Toascii:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of UTF-8 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-8 chars in and try to convert it to an ASCII
Packit 423ecb
 * block of chars out.
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 *     if the return value is positive, else unpredictable.
Packit 423ecb
 * The value of @outlen after return is the number of octets consumed.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
UTF8Toascii(unsigned char* out, int *outlen,
Packit 423ecb
              const unsigned char* in, int *inlen) {
Packit 423ecb
    const unsigned char* processed = in;
Packit 423ecb
    const unsigned char* outend;
Packit 423ecb
    const unsigned char* outstart = out;
Packit 423ecb
    const unsigned char* instart = in;
Packit 423ecb
    const unsigned char* inend;
Packit 423ecb
    unsigned int c, d;
Packit 423ecb
    int trailing;
Packit 423ecb
Packit 423ecb
    if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
Packit 423ecb
    if (in == NULL) {
Packit 423ecb
        /*
Packit 423ecb
	 * initialization nothing to do
Packit 423ecb
	 */
Packit 423ecb
	*outlen = 0;
Packit 423ecb
	*inlen = 0;
Packit 423ecb
	return(0);
Packit 423ecb
    }
Packit 423ecb
    inend = in + (*inlen);
Packit 423ecb
    outend = out + (*outlen);
Packit 423ecb
    while (in < inend) {
Packit 423ecb
	d = *in++;
Packit 423ecb
	if      (d < 0x80)  { c= d; trailing= 0; }
Packit 423ecb
	else if (d < 0xC0) {
Packit 423ecb
	    /* trailing byte in leading position */
Packit 423ecb
	    *outlen = out - outstart;
Packit 423ecb
	    *inlen = processed - instart;
Packit 423ecb
	    return(-2);
Packit 423ecb
        } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
Packit 423ecb
        else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
Packit 423ecb
        else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
Packit 423ecb
	else {
Packit 423ecb
	    /* no chance for this in Ascii */
Packit 423ecb
	    *outlen = out - outstart;
Packit 423ecb
	    *inlen = processed - instart;
Packit 423ecb
	    return(-2);
Packit 423ecb
	}
Packit 423ecb
Packit 423ecb
	if (inend - in < trailing) {
Packit 423ecb
	    break;
Packit 423ecb
	}
Packit 423ecb
Packit 423ecb
	for ( ; trailing; trailing--) {
Packit 423ecb
	    if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))
Packit 423ecb
		break;
Packit 423ecb
	    c <<= 6;
Packit 423ecb
	    c |= d & 0x3F;
Packit 423ecb
	}
Packit 423ecb
Packit 423ecb
	/* assertion: c is a single UTF-4 value */
Packit 423ecb
	if (c < 0x80) {
Packit 423ecb
	    if (out >= outend)
Packit 423ecb
		break;
Packit 423ecb
	    *out++ = c;
Packit 423ecb
	} else {
Packit 423ecb
	    /* no chance for this in Ascii */
Packit 423ecb
	    *outlen = out - outstart;
Packit 423ecb
	    *inlen = processed - instart;
Packit 423ecb
	    return(-2);
Packit 423ecb
	}
Packit 423ecb
	processed = in;
Packit 423ecb
    }
Packit 423ecb
    *outlen = out - outstart;
Packit 423ecb
    *inlen = processed - instart;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
#endif /* LIBXML_OUTPUT_ENABLED */
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * isolat1ToUTF8:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of ISO Latin 1 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Take a block of ISO Latin 1 chars in and try to convert it to an UTF-8
Packit 423ecb
 * block of chars out.
Packit 423ecb
 * Returns the number of bytes written if success, or -1 otherwise
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 *     if the return value is positive, else unpredictable.
Packit 423ecb
 * The value of @outlen after return is the number of octets consumed.
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
isolat1ToUTF8(unsigned char* out, int *outlen,
Packit 423ecb
              const unsigned char* in, int *inlen) {
Packit 423ecb
    unsigned char* outstart = out;
Packit 423ecb
    const unsigned char* base = in;
Packit 423ecb
    unsigned char* outend;
Packit 423ecb
    const unsigned char* inend;
Packit 423ecb
    const unsigned char* instop;
Packit 423ecb
Packit 423ecb
    if ((out == NULL) || (in == NULL) || (outlen == NULL) || (inlen == NULL))
Packit 423ecb
	return(-1);
Packit 423ecb
Packit 423ecb
    outend = out + *outlen;
Packit 423ecb
    inend = in + (*inlen);
Packit 423ecb
    instop = inend;
Packit 423ecb
Packit 423ecb
    while ((in < inend) && (out < outend - 1)) {
Packit 423ecb
	if (*in >= 0x80) {
Packit 423ecb
	    *out++ = (((*in) >>  6) & 0x1F) | 0xC0;
Packit 423ecb
            *out++ = ((*in) & 0x3F) | 0x80;
Packit 423ecb
	    ++in;
Packit 423ecb
	}
Packit 423ecb
	if ((instop - in) > (outend - out)) instop = in + (outend - out);
Packit 423ecb
	while ((in < instop) && (*in < 0x80)) {
Packit 423ecb
	    *out++ = *in++;
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    if ((in < inend) && (out < outend) && (*in < 0x80)) {
Packit 423ecb
        *out++ = *in++;
Packit 423ecb
    }
Packit 423ecb
    *outlen = out - outstart;
Packit 423ecb
    *inlen = in - base;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * UTF8ToUTF8:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @inb:  a pointer to an array of UTF-8 chars
Packit 423ecb
 * @inlenb:  the length of @in in UTF-8 chars
Packit 423ecb
 *
Packit 423ecb
 * No op copy operation for UTF8 handling.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of bytes written, or -1 if lack of space.
Packit 423ecb
 *     The value of *inlen after return is the number of octets consumed
Packit 423ecb
 *     if the return value is positive, else unpredictable.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
UTF8ToUTF8(unsigned char* out, int *outlen,
Packit 423ecb
           const unsigned char* inb, int *inlenb)
Packit 423ecb
{
Packit 423ecb
    int len;
Packit 423ecb
Packit 423ecb
    if ((out == NULL) || (outlen == NULL) || (inlenb == NULL))
Packit 423ecb
	return(-1);
Packit 423ecb
    if (inb == NULL) {
Packit 423ecb
        /* inb == NULL means output is initialized. */
Packit 423ecb
        *outlen = 0;
Packit 423ecb
        *inlenb = 0;
Packit 423ecb
        return(0);
Packit 423ecb
    }
Packit 423ecb
    if (*outlen > *inlenb) {
Packit 423ecb
	len = *inlenb;
Packit 423ecb
    } else {
Packit 423ecb
	len = *outlen;
Packit 423ecb
    }
Packit 423ecb
    if (len < 0)
Packit 423ecb
	return(-1);
Packit 423ecb
Packit 423ecb
    memcpy(out, inb, len);
Packit 423ecb
Packit 423ecb
    *outlen = len;
Packit 423ecb
    *inlenb = len;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_OUTPUT_ENABLED
Packit 423ecb
/**
Packit 423ecb
 * UTF8Toisolat1:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of UTF-8 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-8 chars in and try to convert it to an ISO Latin 1
Packit 423ecb
 * block of chars out.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of bytes written if success, -2 if the transcoding fails,
Packit 423ecb
           or -1 otherwise
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 *     if the return value is positive, else unpredictable.
Packit 423ecb
 * The value of @outlen after return is the number of octets consumed.
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
UTF8Toisolat1(unsigned char* out, int *outlen,
Packit 423ecb
              const unsigned char* in, int *inlen) {
Packit 423ecb
    const unsigned char* processed = in;
Packit 423ecb
    const unsigned char* outend;
Packit 423ecb
    const unsigned char* outstart = out;
Packit 423ecb
    const unsigned char* instart = in;
Packit 423ecb
    const unsigned char* inend;
Packit 423ecb
    unsigned int c, d;
Packit 423ecb
    int trailing;
Packit 423ecb
Packit 423ecb
    if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
Packit 423ecb
    if (in == NULL) {
Packit 423ecb
        /*
Packit 423ecb
	 * initialization nothing to do
Packit 423ecb
	 */
Packit 423ecb
	*outlen = 0;
Packit 423ecb
	*inlen = 0;
Packit 423ecb
	return(0);
Packit 423ecb
    }
Packit 423ecb
    inend = in + (*inlen);
Packit 423ecb
    outend = out + (*outlen);
Packit 423ecb
    while (in < inend) {
Packit 423ecb
	d = *in++;
Packit 423ecb
	if      (d < 0x80)  { c= d; trailing= 0; }
Packit 423ecb
	else if (d < 0xC0) {
Packit 423ecb
	    /* trailing byte in leading position */
Packit 423ecb
	    *outlen = out - outstart;
Packit 423ecb
	    *inlen = processed - instart;
Packit 423ecb
	    return(-2);
Packit 423ecb
        } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
Packit 423ecb
        else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
Packit 423ecb
        else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
Packit 423ecb
	else {
Packit 423ecb
	    /* no chance for this in IsoLat1 */
Packit 423ecb
	    *outlen = out - outstart;
Packit 423ecb
	    *inlen = processed - instart;
Packit 423ecb
	    return(-2);
Packit 423ecb
	}
Packit 423ecb
Packit 423ecb
	if (inend - in < trailing) {
Packit 423ecb
	    break;
Packit 423ecb
	}
Packit 423ecb
Packit 423ecb
	for ( ; trailing; trailing--) {
Packit 423ecb
	    if (in >= inend)
Packit 423ecb
		break;
Packit 423ecb
	    if (((d= *in++) & 0xC0) != 0x80) {
Packit 423ecb
		*outlen = out - outstart;
Packit 423ecb
		*inlen = processed - instart;
Packit 423ecb
		return(-2);
Packit 423ecb
	    }
Packit 423ecb
	    c <<= 6;
Packit 423ecb
	    c |= d & 0x3F;
Packit 423ecb
	}
Packit 423ecb
Packit 423ecb
	/* assertion: c is a single UTF-4 value */
Packit 423ecb
	if (c <= 0xFF) {
Packit 423ecb
	    if (out >= outend)
Packit 423ecb
		break;
Packit 423ecb
	    *out++ = c;
Packit 423ecb
	} else {
Packit 423ecb
	    /* no chance for this in IsoLat1 */
Packit 423ecb
	    *outlen = out - outstart;
Packit 423ecb
	    *inlen = processed - instart;
Packit 423ecb
	    return(-2);
Packit 423ecb
	}
Packit 423ecb
	processed = in;
Packit 423ecb
    }
Packit 423ecb
    *outlen = out - outstart;
Packit 423ecb
    *inlen = processed - instart;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
#endif /* LIBXML_OUTPUT_ENABLED */
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * UTF16LEToUTF8:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @inb:  a pointer to an array of UTF-16LE passwd as a byte array
Packit 423ecb
 * @inlenb:  the length of @in in UTF-16LE chars
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-16LE ushorts in and try to convert it to an UTF-8
Packit 423ecb
 * block of chars out. This function assumes the endian property
Packit 423ecb
 * is the same between the native type of this machine and the
Packit 423ecb
 * inputed one.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of bytes written, or -1 if lack of space, or -2
Packit 423ecb
 *     if the transcoding fails (if *in is not a valid utf16 string)
Packit 423ecb
 *     The value of *inlen after return is the number of octets consumed
Packit 423ecb
 *     if the return value is positive, else unpredictable.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
UTF16LEToUTF8(unsigned char* out, int *outlen,
Packit 423ecb
            const unsigned char* inb, int *inlenb)
Packit 423ecb
{
Packit 423ecb
    unsigned char* outstart = out;
Packit 423ecb
    const unsigned char* processed = inb;
Packit 423ecb
    unsigned char* outend = out + *outlen;
Packit 423ecb
    unsigned short* in = (unsigned short*) inb;
Packit 423ecb
    unsigned short* inend;
Packit 423ecb
    unsigned int c, d, inlen;
Packit 423ecb
    unsigned char *tmp;
Packit 423ecb
    int bits;
Packit 423ecb
Packit 423ecb
    if ((*inlenb % 2) == 1)
Packit 423ecb
        (*inlenb)--;
Packit 423ecb
    inlen = *inlenb / 2;
Packit 423ecb
    inend = in + inlen;
Packit 423ecb
    while ((in < inend) && (out - outstart + 5 < *outlen)) {
Packit 423ecb
        if (xmlLittleEndian) {
Packit 423ecb
	    c= *in++;
Packit 423ecb
	} else {
Packit 423ecb
	    tmp = (unsigned char *) in;
Packit 423ecb
	    c = *tmp++;
Packit 423ecb
	    c = c | (((unsigned int)*tmp) << 8);
Packit 423ecb
	    in++;
Packit 423ecb
	}
Packit 423ecb
        if ((c & 0xFC00) == 0xD800) {    /* surrogates */
Packit 423ecb
	    if (in >= inend) {           /* (in > inend) shouldn't happens */
Packit 423ecb
		break;
Packit 423ecb
	    }
Packit 423ecb
	    if (xmlLittleEndian) {
Packit 423ecb
		d = *in++;
Packit 423ecb
	    } else {
Packit 423ecb
		tmp = (unsigned char *) in;
Packit 423ecb
		d = *tmp++;
Packit 423ecb
		d = d | (((unsigned int)*tmp) << 8);
Packit 423ecb
		in++;
Packit 423ecb
	    }
Packit 423ecb
            if ((d & 0xFC00) == 0xDC00) {
Packit 423ecb
                c &= 0x03FF;
Packit 423ecb
                c <<= 10;
Packit 423ecb
                c |= d & 0x03FF;
Packit 423ecb
                c += 0x10000;
Packit 423ecb
            }
Packit 423ecb
            else {
Packit 423ecb
		*outlen = out - outstart;
Packit 423ecb
		*inlenb = processed - inb;
Packit 423ecb
	        return(-2);
Packit 423ecb
	    }
Packit 423ecb
        }
Packit 423ecb
Packit 423ecb
	/* assertion: c is a single UTF-4 value */
Packit 423ecb
        if (out >= outend)
Packit 423ecb
	    break;
Packit 423ecb
        if      (c <    0x80) {  *out++=  c;                bits= -6; }
Packit 423ecb
        else if (c <   0x800) {  *out++= ((c >>  6) & 0x1F) | 0xC0;  bits=  0; }
Packit 423ecb
        else if (c < 0x10000) {  *out++= ((c >> 12) & 0x0F) | 0xE0;  bits=  6; }
Packit 423ecb
        else                  {  *out++= ((c >> 18) & 0x07) | 0xF0;  bits= 12; }
Packit 423ecb
Packit 423ecb
        for ( ; bits >= 0; bits-= 6) {
Packit 423ecb
            if (out >= outend)
Packit 423ecb
	        break;
Packit 423ecb
            *out++= ((c >> bits) & 0x3F) | 0x80;
Packit 423ecb
        }
Packit 423ecb
	processed = (const unsigned char*) in;
Packit 423ecb
    }
Packit 423ecb
    *outlen = out - outstart;
Packit 423ecb
    *inlenb = processed - inb;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_OUTPUT_ENABLED
Packit 423ecb
/**
Packit 423ecb
 * UTF8ToUTF16LE:
Packit 423ecb
 * @outb:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @outb
Packit 423ecb
 * @in:  a pointer to an array of UTF-8 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-8 chars in and try to convert it to an UTF-16LE
Packit 423ecb
 * block of chars out.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of bytes written, or -1 if lack of space, or -2
Packit 423ecb
 *     if the transcoding failed.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
UTF8ToUTF16LE(unsigned char* outb, int *outlen,
Packit 423ecb
            const unsigned char* in, int *inlen)
Packit 423ecb
{
Packit 423ecb
    unsigned short* out = (unsigned short*) outb;
Packit 423ecb
    const unsigned char* processed = in;
Packit 423ecb
    const unsigned char *const instart = in;
Packit 423ecb
    unsigned short* outstart= out;
Packit 423ecb
    unsigned short* outend;
Packit 423ecb
    const unsigned char* inend;
Packit 423ecb
    unsigned int c, d;
Packit 423ecb
    int trailing;
Packit 423ecb
    unsigned char *tmp;
Packit 423ecb
    unsigned short tmp1, tmp2;
Packit 423ecb
Packit 423ecb
    /* UTF16LE encoding has no BOM */
Packit 423ecb
    if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
Packit 423ecb
    if (in == NULL) {
Packit 423ecb
	*outlen = 0;
Packit 423ecb
	*inlen = 0;
Packit 423ecb
	return(0);
Packit 423ecb
    }
Packit 423ecb
    inend= in + *inlen;
Packit 423ecb
    outend = out + (*outlen / 2);
Packit 423ecb
    while (in < inend) {
Packit 423ecb
      d= *in++;
Packit 423ecb
      if      (d < 0x80)  { c= d; trailing= 0; }
Packit 423ecb
      else if (d < 0xC0) {
Packit 423ecb
          /* trailing byte in leading position */
Packit 423ecb
	  *outlen = (out - outstart) * 2;
Packit 423ecb
	  *inlen = processed - instart;
Packit 423ecb
	  return(-2);
Packit 423ecb
      } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
Packit 423ecb
      else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
Packit 423ecb
      else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
Packit 423ecb
      else {
Packit 423ecb
	/* no chance for this in UTF-16 */
Packit 423ecb
	*outlen = (out - outstart) * 2;
Packit 423ecb
	*inlen = processed - instart;
Packit 423ecb
	return(-2);
Packit 423ecb
      }
Packit 423ecb
Packit 423ecb
      if (inend - in < trailing) {
Packit 423ecb
          break;
Packit 423ecb
      }
Packit 423ecb
Packit 423ecb
      for ( ; trailing; trailing--) {
Packit 423ecb
          if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))
Packit 423ecb
	      break;
Packit 423ecb
          c <<= 6;
Packit 423ecb
          c |= d & 0x3F;
Packit 423ecb
      }
Packit 423ecb
Packit 423ecb
      /* assertion: c is a single UTF-4 value */
Packit 423ecb
        if (c < 0x10000) {
Packit 423ecb
            if (out >= outend)
Packit 423ecb
	        break;
Packit 423ecb
	    if (xmlLittleEndian) {
Packit 423ecb
		*out++ = c;
Packit 423ecb
	    } else {
Packit 423ecb
		tmp = (unsigned char *) out;
Packit 423ecb
		*tmp = c ;
Packit 423ecb
		*(tmp + 1) = c >> 8 ;
Packit 423ecb
		out++;
Packit 423ecb
	    }
Packit 423ecb
        }
Packit 423ecb
        else if (c < 0x110000) {
Packit 423ecb
            if (out+1 >= outend)
Packit 423ecb
	        break;
Packit 423ecb
            c -= 0x10000;
Packit 423ecb
	    if (xmlLittleEndian) {
Packit 423ecb
		*out++ = 0xD800 | (c >> 10);
Packit 423ecb
		*out++ = 0xDC00 | (c & 0x03FF);
Packit 423ecb
	    } else {
Packit 423ecb
		tmp1 = 0xD800 | (c >> 10);
Packit 423ecb
		tmp = (unsigned char *) out;
Packit 423ecb
		*tmp = (unsigned char) tmp1;
Packit 423ecb
		*(tmp + 1) = tmp1 >> 8;
Packit 423ecb
		out++;
Packit 423ecb
Packit 423ecb
		tmp2 = 0xDC00 | (c & 0x03FF);
Packit 423ecb
		tmp = (unsigned char *) out;
Packit 423ecb
		*tmp  = (unsigned char) tmp2;
Packit 423ecb
		*(tmp + 1) = tmp2 >> 8;
Packit 423ecb
		out++;
Packit 423ecb
	    }
Packit 423ecb
        }
Packit 423ecb
        else
Packit 423ecb
	    break;
Packit 423ecb
	processed = in;
Packit 423ecb
    }
Packit 423ecb
    *outlen = (out - outstart) * 2;
Packit 423ecb
    *inlen = processed - instart;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * UTF8ToUTF16:
Packit 423ecb
 * @outb:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @outb
Packit 423ecb
 * @in:  a pointer to an array of UTF-8 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-8 chars in and try to convert it to an UTF-16
Packit 423ecb
 * block of chars out.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of bytes written, or -1 if lack of space, or -2
Packit 423ecb
 *     if the transcoding failed.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
UTF8ToUTF16(unsigned char* outb, int *outlen,
Packit 423ecb
            const unsigned char* in, int *inlen)
Packit 423ecb
{
Packit 423ecb
    if (in == NULL) {
Packit 423ecb
	/*
Packit 423ecb
	 * initialization, add the Byte Order Mark for UTF-16LE
Packit 423ecb
	 */
Packit 423ecb
        if (*outlen >= 2) {
Packit 423ecb
	    outb[0] = 0xFF;
Packit 423ecb
	    outb[1] = 0xFE;
Packit 423ecb
	    *outlen = 2;
Packit 423ecb
	    *inlen = 0;
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "Added FFFE Byte Order Mark\n");
Packit 423ecb
#endif
Packit 423ecb
	    return(2);
Packit 423ecb
	}
Packit 423ecb
	*outlen = 0;
Packit 423ecb
	*inlen = 0;
Packit 423ecb
	return(0);
Packit 423ecb
    }
Packit 423ecb
    return (UTF8ToUTF16LE(outb, outlen, in, inlen));
Packit 423ecb
}
Packit 423ecb
#endif /* LIBXML_OUTPUT_ENABLED */
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * UTF16BEToUTF8:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @inb:  a pointer to an array of UTF-16 passed as a byte array
Packit 423ecb
 * @inlenb:  the length of @in in UTF-16 chars
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-16 ushorts in and try to convert it to an UTF-8
Packit 423ecb
 * block of chars out. This function assumes the endian property
Packit 423ecb
 * is the same between the native type of this machine and the
Packit 423ecb
 * inputed one.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of bytes written, or -1 if lack of space, or -2
Packit 423ecb
 *     if the transcoding fails (if *in is not a valid utf16 string)
Packit 423ecb
 * The value of *inlen after return is the number of octets consumed
Packit 423ecb
 *     if the return value is positive, else unpredictable.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
UTF16BEToUTF8(unsigned char* out, int *outlen,
Packit 423ecb
            const unsigned char* inb, int *inlenb)
Packit 423ecb
{
Packit 423ecb
    unsigned char* outstart = out;
Packit 423ecb
    const unsigned char* processed = inb;
Packit 423ecb
    unsigned char* outend = out + *outlen;
Packit 423ecb
    unsigned short* in = (unsigned short*) inb;
Packit 423ecb
    unsigned short* inend;
Packit 423ecb
    unsigned int c, d, inlen;
Packit 423ecb
    unsigned char *tmp;
Packit 423ecb
    int bits;
Packit 423ecb
Packit 423ecb
    if ((*inlenb % 2) == 1)
Packit 423ecb
        (*inlenb)--;
Packit 423ecb
    inlen = *inlenb / 2;
Packit 423ecb
    inend= in + inlen;
Packit 423ecb
    while (in < inend) {
Packit 423ecb
	if (xmlLittleEndian) {
Packit 423ecb
	    tmp = (unsigned char *) in;
Packit 423ecb
	    c = *tmp++;
Packit 423ecb
	    c = c << 8;
Packit 423ecb
	    c = c | (unsigned int) *tmp;
Packit 423ecb
	    in++;
Packit 423ecb
	} else {
Packit 423ecb
	    c= *in++;
Packit 423ecb
	}
Packit 423ecb
        if ((c & 0xFC00) == 0xD800) {    /* surrogates */
Packit 423ecb
	    if (in >= inend) {           /* (in > inend) shouldn't happens */
Packit 423ecb
		*outlen = out - outstart;
Packit 423ecb
		*inlenb = processed - inb;
Packit 423ecb
	        return(-2);
Packit 423ecb
	    }
Packit 423ecb
	    if (xmlLittleEndian) {
Packit 423ecb
		tmp = (unsigned char *) in;
Packit 423ecb
		d = *tmp++;
Packit 423ecb
		d = d << 8;
Packit 423ecb
		d = d | (unsigned int) *tmp;
Packit 423ecb
		in++;
Packit 423ecb
	    } else {
Packit 423ecb
		d= *in++;
Packit 423ecb
	    }
Packit 423ecb
            if ((d & 0xFC00) == 0xDC00) {
Packit 423ecb
                c &= 0x03FF;
Packit 423ecb
                c <<= 10;
Packit 423ecb
                c |= d & 0x03FF;
Packit 423ecb
                c += 0x10000;
Packit 423ecb
            }
Packit 423ecb
            else {
Packit 423ecb
		*outlen = out - outstart;
Packit 423ecb
		*inlenb = processed - inb;
Packit 423ecb
	        return(-2);
Packit 423ecb
	    }
Packit 423ecb
        }
Packit 423ecb
Packit 423ecb
	/* assertion: c is a single UTF-4 value */
Packit 423ecb
        if (out >= outend)
Packit 423ecb
	    break;
Packit 423ecb
        if      (c <    0x80) {  *out++=  c;                bits= -6; }
Packit 423ecb
        else if (c <   0x800) {  *out++= ((c >>  6) & 0x1F) | 0xC0;  bits=  0; }
Packit 423ecb
        else if (c < 0x10000) {  *out++= ((c >> 12) & 0x0F) | 0xE0;  bits=  6; }
Packit 423ecb
        else                  {  *out++= ((c >> 18) & 0x07) | 0xF0;  bits= 12; }
Packit 423ecb
Packit 423ecb
        for ( ; bits >= 0; bits-= 6) {
Packit 423ecb
            if (out >= outend)
Packit 423ecb
	        break;
Packit 423ecb
            *out++= ((c >> bits) & 0x3F) | 0x80;
Packit 423ecb
        }
Packit 423ecb
	processed = (const unsigned char*) in;
Packit 423ecb
    }
Packit 423ecb
    *outlen = out - outstart;
Packit 423ecb
    *inlenb = processed - inb;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_OUTPUT_ENABLED
Packit 423ecb
/**
Packit 423ecb
 * UTF8ToUTF16BE:
Packit 423ecb
 * @outb:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @outb
Packit 423ecb
 * @in:  a pointer to an array of UTF-8 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-8 chars in and try to convert it to an UTF-16BE
Packit 423ecb
 * block of chars out.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of byte written, or -1 by lack of space, or -2
Packit 423ecb
 *     if the transcoding failed.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
UTF8ToUTF16BE(unsigned char* outb, int *outlen,
Packit 423ecb
            const unsigned char* in, int *inlen)
Packit 423ecb
{
Packit 423ecb
    unsigned short* out = (unsigned short*) outb;
Packit 423ecb
    const unsigned char* processed = in;
Packit 423ecb
    const unsigned char *const instart = in;
Packit 423ecb
    unsigned short* outstart= out;
Packit 423ecb
    unsigned short* outend;
Packit 423ecb
    const unsigned char* inend;
Packit 423ecb
    unsigned int c, d;
Packit 423ecb
    int trailing;
Packit 423ecb
    unsigned char *tmp;
Packit 423ecb
    unsigned short tmp1, tmp2;
Packit 423ecb
Packit 423ecb
    /* UTF-16BE has no BOM */
Packit 423ecb
    if ((outb == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1);
Packit 423ecb
    if (in == NULL) {
Packit 423ecb
	*outlen = 0;
Packit 423ecb
	*inlen = 0;
Packit 423ecb
	return(0);
Packit 423ecb
    }
Packit 423ecb
    inend= in + *inlen;
Packit 423ecb
    outend = out + (*outlen / 2);
Packit 423ecb
    while (in < inend) {
Packit 423ecb
      d= *in++;
Packit 423ecb
      if      (d < 0x80)  { c= d; trailing= 0; }
Packit 423ecb
      else if (d < 0xC0)  {
Packit 423ecb
          /* trailing byte in leading position */
Packit 423ecb
	  *outlen = out - outstart;
Packit 423ecb
	  *inlen = processed - instart;
Packit 423ecb
	  return(-2);
Packit 423ecb
      } else if (d < 0xE0)  { c= d & 0x1F; trailing= 1; }
Packit 423ecb
      else if (d < 0xF0)  { c= d & 0x0F; trailing= 2; }
Packit 423ecb
      else if (d < 0xF8)  { c= d & 0x07; trailing= 3; }
Packit 423ecb
      else {
Packit 423ecb
          /* no chance for this in UTF-16 */
Packit 423ecb
	  *outlen = out - outstart;
Packit 423ecb
	  *inlen = processed - instart;
Packit 423ecb
	  return(-2);
Packit 423ecb
      }
Packit 423ecb
Packit 423ecb
      if (inend - in < trailing) {
Packit 423ecb
          break;
Packit 423ecb
      }
Packit 423ecb
Packit 423ecb
      for ( ; trailing; trailing--) {
Packit 423ecb
          if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))  break;
Packit 423ecb
          c <<= 6;
Packit 423ecb
          c |= d & 0x3F;
Packit 423ecb
      }
Packit 423ecb
Packit 423ecb
      /* assertion: c is a single UTF-4 value */
Packit 423ecb
        if (c < 0x10000) {
Packit 423ecb
            if (out >= outend)  break;
Packit 423ecb
	    if (xmlLittleEndian) {
Packit 423ecb
		tmp = (unsigned char *) out;
Packit 423ecb
		*tmp = c >> 8;
Packit 423ecb
		*(tmp + 1) = c;
Packit 423ecb
		out++;
Packit 423ecb
	    } else {
Packit 423ecb
		*out++ = c;
Packit 423ecb
	    }
Packit 423ecb
        }
Packit 423ecb
        else if (c < 0x110000) {
Packit 423ecb
            if (out+1 >= outend)  break;
Packit 423ecb
            c -= 0x10000;
Packit 423ecb
	    if (xmlLittleEndian) {
Packit 423ecb
		tmp1 = 0xD800 | (c >> 10);
Packit 423ecb
		tmp = (unsigned char *) out;
Packit 423ecb
		*tmp = tmp1 >> 8;
Packit 423ecb
		*(tmp + 1) = (unsigned char) tmp1;
Packit 423ecb
		out++;
Packit 423ecb
Packit 423ecb
		tmp2 = 0xDC00 | (c & 0x03FF);
Packit 423ecb
		tmp = (unsigned char *) out;
Packit 423ecb
		*tmp = tmp2 >> 8;
Packit 423ecb
		*(tmp + 1) = (unsigned char) tmp2;
Packit 423ecb
		out++;
Packit 423ecb
	    } else {
Packit 423ecb
		*out++ = 0xD800 | (c >> 10);
Packit 423ecb
		*out++ = 0xDC00 | (c & 0x03FF);
Packit 423ecb
	    }
Packit 423ecb
        }
Packit 423ecb
        else
Packit 423ecb
	    break;
Packit 423ecb
	processed = in;
Packit 423ecb
    }
Packit 423ecb
    *outlen = (out - outstart) * 2;
Packit 423ecb
    *inlen = processed - instart;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
#endif /* LIBXML_OUTPUT_ENABLED */
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *		Generic encoding handling routines			*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlDetectCharEncoding:
Packit 423ecb
 * @in:  a pointer to the first bytes of the XML entity, must be at least
Packit 423ecb
 *       2 bytes long (at least 4 if encoding is UTF4 variant).
Packit 423ecb
 * @len:  pointer to the length of the buffer
Packit 423ecb
 *
Packit 423ecb
 * Guess the encoding of the entity using the first bytes of the entity content
Packit 423ecb
 * according to the non-normative appendix F of the XML-1.0 recommendation.
Packit 423ecb
 *
Packit 423ecb
 * Returns one of the XML_CHAR_ENCODING_... values.
Packit 423ecb
 */
Packit 423ecb
xmlCharEncoding
Packit 423ecb
xmlDetectCharEncoding(const unsigned char* in, int len)
Packit 423ecb
{
Packit 423ecb
    if (in == NULL)
Packit 423ecb
        return(XML_CHAR_ENCODING_NONE);
Packit 423ecb
    if (len >= 4) {
Packit 423ecb
	if ((in[0] == 0x00) && (in[1] == 0x00) &&
Packit 423ecb
	    (in[2] == 0x00) && (in[3] == 0x3C))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UCS4BE);
Packit 423ecb
	if ((in[0] == 0x3C) && (in[1] == 0x00) &&
Packit 423ecb
	    (in[2] == 0x00) && (in[3] == 0x00))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UCS4LE);
Packit 423ecb
	if ((in[0] == 0x00) && (in[1] == 0x00) &&
Packit 423ecb
	    (in[2] == 0x3C) && (in[3] == 0x00))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UCS4_2143);
Packit 423ecb
	if ((in[0] == 0x00) && (in[1] == 0x3C) &&
Packit 423ecb
	    (in[2] == 0x00) && (in[3] == 0x00))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UCS4_3412);
Packit 423ecb
	if ((in[0] == 0x4C) && (in[1] == 0x6F) &&
Packit 423ecb
	    (in[2] == 0xA7) && (in[3] == 0x94))
Packit 423ecb
	    return(XML_CHAR_ENCODING_EBCDIC);
Packit 423ecb
	if ((in[0] == 0x3C) && (in[1] == 0x3F) &&
Packit 423ecb
	    (in[2] == 0x78) && (in[3] == 0x6D))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UTF8);
Packit 423ecb
	/*
Packit 423ecb
	 * Although not part of the recommendation, we also
Packit 423ecb
	 * attempt an "auto-recognition" of UTF-16LE and
Packit 423ecb
	 * UTF-16BE encodings.
Packit 423ecb
	 */
Packit 423ecb
	if ((in[0] == 0x3C) && (in[1] == 0x00) &&
Packit 423ecb
	    (in[2] == 0x3F) && (in[3] == 0x00))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UTF16LE);
Packit 423ecb
	if ((in[0] == 0x00) && (in[1] == 0x3C) &&
Packit 423ecb
	    (in[2] == 0x00) && (in[3] == 0x3F))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UTF16BE);
Packit 423ecb
    }
Packit 423ecb
    if (len >= 3) {
Packit 423ecb
	/*
Packit 423ecb
	 * Errata on XML-1.0 June 20 2001
Packit 423ecb
	 * We now allow an UTF8 encoded BOM
Packit 423ecb
	 */
Packit 423ecb
	if ((in[0] == 0xEF) && (in[1] == 0xBB) &&
Packit 423ecb
	    (in[2] == 0xBF))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UTF8);
Packit 423ecb
    }
Packit 423ecb
    /* For UTF-16 we can recognize by the BOM */
Packit 423ecb
    if (len >= 2) {
Packit 423ecb
	if ((in[0] == 0xFE) && (in[1] == 0xFF))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UTF16BE);
Packit 423ecb
	if ((in[0] == 0xFF) && (in[1] == 0xFE))
Packit 423ecb
	    return(XML_CHAR_ENCODING_UTF16LE);
Packit 423ecb
    }
Packit 423ecb
    return(XML_CHAR_ENCODING_NONE);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCleanupEncodingAliases:
Packit 423ecb
 *
Packit 423ecb
 * Unregisters all aliases
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlCleanupEncodingAliases(void) {
Packit 423ecb
    int i;
Packit 423ecb
Packit 423ecb
    if (xmlCharEncodingAliases == NULL)
Packit 423ecb
	return;
Packit 423ecb
Packit 423ecb
    for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
Packit 423ecb
	if (xmlCharEncodingAliases[i].name != NULL)
Packit 423ecb
	    xmlFree((char *) xmlCharEncodingAliases[i].name);
Packit 423ecb
	if (xmlCharEncodingAliases[i].alias != NULL)
Packit 423ecb
	    xmlFree((char *) xmlCharEncodingAliases[i].alias);
Packit 423ecb
    }
Packit 423ecb
    xmlCharEncodingAliasesNb = 0;
Packit 423ecb
    xmlCharEncodingAliasesMax = 0;
Packit 423ecb
    xmlFree(xmlCharEncodingAliases);
Packit 423ecb
    xmlCharEncodingAliases = NULL;
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlGetEncodingAlias:
Packit 423ecb
 * @alias:  the alias name as parsed, in UTF-8 format (ASCII actually)
Packit 423ecb
 *
Packit 423ecb
 * Lookup an encoding name for the given alias.
Packit 423ecb
 *
Packit 423ecb
 * Returns NULL if not found, otherwise the original name
Packit 423ecb
 */
Packit 423ecb
const char *
Packit 423ecb
xmlGetEncodingAlias(const char *alias) {
Packit 423ecb
    int i;
Packit 423ecb
    char upper[100];
Packit 423ecb
Packit 423ecb
    if (alias == NULL)
Packit 423ecb
	return(NULL);
Packit 423ecb
Packit 423ecb
    if (xmlCharEncodingAliases == NULL)
Packit 423ecb
	return(NULL);
Packit 423ecb
Packit 423ecb
    for (i = 0;i < 99;i++) {
Packit 423ecb
        upper[i] = toupper(alias[i]);
Packit 423ecb
	if (upper[i] == 0) break;
Packit 423ecb
    }
Packit 423ecb
    upper[i] = 0;
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Walk down the list looking for a definition of the alias
Packit 423ecb
     */
Packit 423ecb
    for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
Packit 423ecb
	if (!strcmp(xmlCharEncodingAliases[i].alias, upper)) {
Packit 423ecb
	    return(xmlCharEncodingAliases[i].name);
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    return(NULL);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlAddEncodingAlias:
Packit 423ecb
 * @name:  the encoding name as parsed, in UTF-8 format (ASCII actually)
Packit 423ecb
 * @alias:  the alias name as parsed, in UTF-8 format (ASCII actually)
Packit 423ecb
 *
Packit 423ecb
 * Registers an alias @alias for an encoding named @name. Existing alias
Packit 423ecb
 * will be overwritten.
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 in case of success, -1 in case of error
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlAddEncodingAlias(const char *name, const char *alias) {
Packit 423ecb
    int i;
Packit 423ecb
    char upper[100];
Packit 423ecb
Packit 423ecb
    if ((name == NULL) || (alias == NULL))
Packit 423ecb
	return(-1);
Packit 423ecb
Packit 423ecb
    for (i = 0;i < 99;i++) {
Packit 423ecb
        upper[i] = toupper(alias[i]);
Packit 423ecb
	if (upper[i] == 0) break;
Packit 423ecb
    }
Packit 423ecb
    upper[i] = 0;
Packit 423ecb
Packit 423ecb
    if (xmlCharEncodingAliases == NULL) {
Packit 423ecb
	xmlCharEncodingAliasesNb = 0;
Packit 423ecb
	xmlCharEncodingAliasesMax = 20;
Packit 423ecb
	xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
Packit 423ecb
	      xmlMalloc(xmlCharEncodingAliasesMax * sizeof(xmlCharEncodingAlias));
Packit 423ecb
	if (xmlCharEncodingAliases == NULL)
Packit 423ecb
	    return(-1);
Packit 423ecb
    } else if (xmlCharEncodingAliasesNb >= xmlCharEncodingAliasesMax) {
Packit 423ecb
	xmlCharEncodingAliasesMax *= 2;
Packit 423ecb
	xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
Packit 423ecb
	      xmlRealloc(xmlCharEncodingAliases,
Packit 423ecb
		         xmlCharEncodingAliasesMax * sizeof(xmlCharEncodingAlias));
Packit 423ecb
    }
Packit 423ecb
    /*
Packit 423ecb
     * Walk down the list looking for a definition of the alias
Packit 423ecb
     */
Packit 423ecb
    for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
Packit 423ecb
	if (!strcmp(xmlCharEncodingAliases[i].alias, upper)) {
Packit 423ecb
	    /*
Packit 423ecb
	     * Replace the definition.
Packit 423ecb
	     */
Packit 423ecb
	    xmlFree((char *) xmlCharEncodingAliases[i].name);
Packit 423ecb
	    xmlCharEncodingAliases[i].name = xmlMemStrdup(name);
Packit 423ecb
	    return(0);
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    /*
Packit 423ecb
     * Add the definition
Packit 423ecb
     */
Packit 423ecb
    xmlCharEncodingAliases[xmlCharEncodingAliasesNb].name = xmlMemStrdup(name);
Packit 423ecb
    xmlCharEncodingAliases[xmlCharEncodingAliasesNb].alias = xmlMemStrdup(upper);
Packit 423ecb
    xmlCharEncodingAliasesNb++;
Packit 423ecb
    return(0);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlDelEncodingAlias:
Packit 423ecb
 * @alias:  the alias name as parsed, in UTF-8 format (ASCII actually)
Packit 423ecb
 *
Packit 423ecb
 * Unregisters an encoding alias @alias
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 in case of success, -1 in case of error
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlDelEncodingAlias(const char *alias) {
Packit 423ecb
    int i;
Packit 423ecb
Packit 423ecb
    if (alias == NULL)
Packit 423ecb
	return(-1);
Packit 423ecb
Packit 423ecb
    if (xmlCharEncodingAliases == NULL)
Packit 423ecb
	return(-1);
Packit 423ecb
    /*
Packit 423ecb
     * Walk down the list looking for a definition of the alias
Packit 423ecb
     */
Packit 423ecb
    for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
Packit 423ecb
	if (!strcmp(xmlCharEncodingAliases[i].alias, alias)) {
Packit 423ecb
	    xmlFree((char *) xmlCharEncodingAliases[i].name);
Packit 423ecb
	    xmlFree((char *) xmlCharEncodingAliases[i].alias);
Packit 423ecb
	    xmlCharEncodingAliasesNb--;
Packit 423ecb
	    memmove(&xmlCharEncodingAliases[i], &xmlCharEncodingAliases[i + 1],
Packit 423ecb
		    sizeof(xmlCharEncodingAlias) * (xmlCharEncodingAliasesNb - i));
Packit 423ecb
	    return(0);
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    return(-1);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlParseCharEncoding:
Packit 423ecb
 * @name:  the encoding name as parsed, in UTF-8 format (ASCII actually)
Packit 423ecb
 *
Packit 423ecb
 * Compare the string to the encoding schemes already known. Note
Packit 423ecb
 * that the comparison is case insensitive accordingly to the section
Packit 423ecb
 * [XML] 4.3.3 Character Encoding in Entities.
Packit 423ecb
 *
Packit 423ecb
 * Returns one of the XML_CHAR_ENCODING_... values or XML_CHAR_ENCODING_NONE
Packit 423ecb
 * if not recognized.
Packit 423ecb
 */
Packit 423ecb
xmlCharEncoding
Packit 423ecb
xmlParseCharEncoding(const char* name)
Packit 423ecb
{
Packit 423ecb
    const char *alias;
Packit 423ecb
    char upper[500];
Packit 423ecb
    int i;
Packit 423ecb
Packit 423ecb
    if (name == NULL)
Packit 423ecb
	return(XML_CHAR_ENCODING_NONE);
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Do the alias resolution
Packit 423ecb
     */
Packit 423ecb
    alias = xmlGetEncodingAlias(name);
Packit 423ecb
    if (alias != NULL)
Packit 423ecb
	name = alias;
Packit 423ecb
Packit 423ecb
    for (i = 0;i < 499;i++) {
Packit 423ecb
        upper[i] = toupper(name[i]);
Packit 423ecb
	if (upper[i] == 0) break;
Packit 423ecb
    }
Packit 423ecb
    upper[i] = 0;
Packit 423ecb
Packit 423ecb
    if (!strcmp(upper, "")) return(XML_CHAR_ENCODING_NONE);
Packit 423ecb
    if (!strcmp(upper, "UTF-8")) return(XML_CHAR_ENCODING_UTF8);
Packit 423ecb
    if (!strcmp(upper, "UTF8")) return(XML_CHAR_ENCODING_UTF8);
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * NOTE: if we were able to parse this, the endianness of UTF16 is
Packit 423ecb
     *       already found and in use
Packit 423ecb
     */
Packit 423ecb
    if (!strcmp(upper, "UTF-16")) return(XML_CHAR_ENCODING_UTF16LE);
Packit 423ecb
    if (!strcmp(upper, "UTF16")) return(XML_CHAR_ENCODING_UTF16LE);
Packit 423ecb
Packit 423ecb
    if (!strcmp(upper, "ISO-10646-UCS-2")) return(XML_CHAR_ENCODING_UCS2);
Packit 423ecb
    if (!strcmp(upper, "UCS-2")) return(XML_CHAR_ENCODING_UCS2);
Packit 423ecb
    if (!strcmp(upper, "UCS2")) return(XML_CHAR_ENCODING_UCS2);
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * NOTE: if we were able to parse this, the endianness of UCS4 is
Packit 423ecb
     *       already found and in use
Packit 423ecb
     */
Packit 423ecb
    if (!strcmp(upper, "ISO-10646-UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
Packit 423ecb
    if (!strcmp(upper, "UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
Packit 423ecb
    if (!strcmp(upper, "UCS4")) return(XML_CHAR_ENCODING_UCS4LE);
Packit 423ecb
Packit 423ecb
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-1")) return(XML_CHAR_ENCODING_8859_1);
Packit 423ecb
    if (!strcmp(upper,  "ISO-LATIN-1")) return(XML_CHAR_ENCODING_8859_1);
Packit 423ecb
    if (!strcmp(upper,  "ISO LATIN 1")) return(XML_CHAR_ENCODING_8859_1);
Packit 423ecb
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-2")) return(XML_CHAR_ENCODING_8859_2);
Packit 423ecb
    if (!strcmp(upper,  "ISO-LATIN-2")) return(XML_CHAR_ENCODING_8859_2);
Packit 423ecb
    if (!strcmp(upper,  "ISO LATIN 2")) return(XML_CHAR_ENCODING_8859_2);
Packit 423ecb
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-3")) return(XML_CHAR_ENCODING_8859_3);
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-4")) return(XML_CHAR_ENCODING_8859_4);
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-5")) return(XML_CHAR_ENCODING_8859_5);
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-6")) return(XML_CHAR_ENCODING_8859_6);
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-7")) return(XML_CHAR_ENCODING_8859_7);
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-8")) return(XML_CHAR_ENCODING_8859_8);
Packit 423ecb
    if (!strcmp(upper,  "ISO-8859-9")) return(XML_CHAR_ENCODING_8859_9);
Packit 423ecb
Packit 423ecb
    if (!strcmp(upper, "ISO-2022-JP")) return(XML_CHAR_ENCODING_2022_JP);
Packit 423ecb
    if (!strcmp(upper, "SHIFT_JIS")) return(XML_CHAR_ENCODING_SHIFT_JIS);
Packit 423ecb
    if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
Packit 423ecb
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext, "Unknown encoding %s\n", name);
Packit 423ecb
#endif
Packit 423ecb
    return(XML_CHAR_ENCODING_ERROR);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlGetCharEncodingName:
Packit 423ecb
 * @enc:  the encoding
Packit 423ecb
 *
Packit 423ecb
 * The "canonical" name for XML encoding.
Packit 423ecb
 * C.f. http://www.w3.org/TR/REC-xml#charencoding
Packit 423ecb
 * Section 4.3.3  Character Encoding in Entities
Packit 423ecb
 *
Packit 423ecb
 * Returns the canonical name for the given encoding
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
const char*
Packit 423ecb
xmlGetCharEncodingName(xmlCharEncoding enc) {
Packit 423ecb
    switch (enc) {
Packit 423ecb
        case XML_CHAR_ENCODING_ERROR:
Packit 423ecb
	    return(NULL);
Packit 423ecb
        case XML_CHAR_ENCODING_NONE:
Packit 423ecb
	    return(NULL);
Packit 423ecb
        case XML_CHAR_ENCODING_UTF8:
Packit 423ecb
	    return("UTF-8");
Packit 423ecb
        case XML_CHAR_ENCODING_UTF16LE:
Packit 423ecb
	    return("UTF-16");
Packit 423ecb
        case XML_CHAR_ENCODING_UTF16BE:
Packit 423ecb
	    return("UTF-16");
Packit 423ecb
        case XML_CHAR_ENCODING_EBCDIC:
Packit 423ecb
            return("EBCDIC");
Packit 423ecb
        case XML_CHAR_ENCODING_UCS4LE:
Packit 423ecb
            return("ISO-10646-UCS-4");
Packit 423ecb
        case XML_CHAR_ENCODING_UCS4BE:
Packit 423ecb
            return("ISO-10646-UCS-4");
Packit 423ecb
        case XML_CHAR_ENCODING_UCS4_2143:
Packit 423ecb
            return("ISO-10646-UCS-4");
Packit 423ecb
        case XML_CHAR_ENCODING_UCS4_3412:
Packit 423ecb
            return("ISO-10646-UCS-4");
Packit 423ecb
        case XML_CHAR_ENCODING_UCS2:
Packit 423ecb
            return("ISO-10646-UCS-2");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_1:
Packit 423ecb
	    return("ISO-8859-1");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_2:
Packit 423ecb
	    return("ISO-8859-2");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_3:
Packit 423ecb
	    return("ISO-8859-3");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_4:
Packit 423ecb
	    return("ISO-8859-4");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_5:
Packit 423ecb
	    return("ISO-8859-5");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_6:
Packit 423ecb
	    return("ISO-8859-6");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_7:
Packit 423ecb
	    return("ISO-8859-7");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_8:
Packit 423ecb
	    return("ISO-8859-8");
Packit 423ecb
        case XML_CHAR_ENCODING_8859_9:
Packit 423ecb
	    return("ISO-8859-9");
Packit 423ecb
        case XML_CHAR_ENCODING_2022_JP:
Packit 423ecb
            return("ISO-2022-JP");
Packit 423ecb
        case XML_CHAR_ENCODING_SHIFT_JIS:
Packit 423ecb
            return("Shift-JIS");
Packit 423ecb
        case XML_CHAR_ENCODING_EUC_JP:
Packit 423ecb
            return("EUC-JP");
Packit 423ecb
	case XML_CHAR_ENCODING_ASCII:
Packit 423ecb
	    return(NULL);
Packit 423ecb
    }
Packit 423ecb
    return(NULL);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *			Char encoding handlers				*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
Packit 423ecb
/* the size should be growable, but it's not a big deal ... */
Packit 423ecb
#define MAX_ENCODING_HANDLERS 50
Packit 423ecb
static xmlCharEncodingHandlerPtr *handlers = NULL;
Packit 423ecb
static int nbCharEncodingHandler = 0;
Packit 423ecb
Packit 423ecb
/*
Packit 423ecb
 * The default is UTF-8 for XML, that's also the default used for the
Packit 423ecb
 * parser internals, so the default encoding handler is NULL
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL;
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlNewCharEncodingHandler:
Packit 423ecb
 * @name:  the encoding name, in UTF-8 format (ASCII actually)
Packit 423ecb
 * @input:  the xmlCharEncodingInputFunc to read that encoding
Packit 423ecb
 * @output:  the xmlCharEncodingOutputFunc to write that encoding
Packit 423ecb
 *
Packit 423ecb
 * Create and registers an xmlCharEncodingHandler.
Packit 423ecb
 *
Packit 423ecb
 * Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error).
Packit 423ecb
 */
Packit 423ecb
xmlCharEncodingHandlerPtr
Packit 423ecb
xmlNewCharEncodingHandler(const char *name,
Packit 423ecb
                          xmlCharEncodingInputFunc input,
Packit 423ecb
                          xmlCharEncodingOutputFunc output) {
Packit 423ecb
    xmlCharEncodingHandlerPtr handler;
Packit 423ecb
    const char *alias;
Packit 423ecb
    char upper[500];
Packit 423ecb
    int i;
Packit 423ecb
    char *up = NULL;
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Do the alias resolution
Packit 423ecb
     */
Packit 423ecb
    alias = xmlGetEncodingAlias(name);
Packit 423ecb
    if (alias != NULL)
Packit 423ecb
	name = alias;
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Keep only the uppercase version of the encoding.
Packit 423ecb
     */
Packit 423ecb
    if (name == NULL) {
Packit 423ecb
        xmlEncodingErr(XML_I18N_NO_NAME,
Packit 423ecb
		       "xmlNewCharEncodingHandler : no name !\n", NULL);
Packit 423ecb
	return(NULL);
Packit 423ecb
    }
Packit 423ecb
    for (i = 0;i < 499;i++) {
Packit 423ecb
        upper[i] = toupper(name[i]);
Packit 423ecb
	if (upper[i] == 0) break;
Packit 423ecb
    }
Packit 423ecb
    upper[i] = 0;
Packit 423ecb
    up = xmlMemStrdup(upper);
Packit 423ecb
    if (up == NULL) {
Packit 423ecb
        xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
Packit 423ecb
	return(NULL);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * allocate and fill-up an handler block.
Packit 423ecb
     */
Packit 423ecb
    handler = (xmlCharEncodingHandlerPtr)
Packit 423ecb
              xmlMalloc(sizeof(xmlCharEncodingHandler));
Packit 423ecb
    if (handler == NULL) {
Packit 423ecb
        xmlFree(up);
Packit 423ecb
        xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
Packit 423ecb
	return(NULL);
Packit 423ecb
    }
Packit 423ecb
    memset(handler, 0, sizeof(xmlCharEncodingHandler));
Packit 423ecb
    handler->input = input;
Packit 423ecb
    handler->output = output;
Packit 423ecb
    handler->name = up;
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_ICONV_ENABLED
Packit 423ecb
    handler->iconv_in = NULL;
Packit 423ecb
    handler->iconv_out = NULL;
Packit 423ecb
#endif
Packit 423ecb
#ifdef LIBXML_ICU_ENABLED
Packit 423ecb
    handler->uconv_in = NULL;
Packit 423ecb
    handler->uconv_out = NULL;
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * registers and returns the handler.
Packit 423ecb
     */
Packit 423ecb
    xmlRegisterCharEncodingHandler(handler);
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
	    "Registered encoding handler for %s\n", name);
Packit 423ecb
#endif
Packit 423ecb
    return(handler);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlInitCharEncodingHandlers:
Packit 423ecb
 *
Packit 423ecb
 * Initialize the char encoding support, it registers the default
Packit 423ecb
 * encoding supported.
Packit 423ecb
 * NOTE: while public, this function usually doesn't need to be called
Packit 423ecb
 *       in normal processing.
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlInitCharEncodingHandlers(void) {
Packit 423ecb
    unsigned short int tst = 0x1234;
Packit 423ecb
    unsigned char *ptr = (unsigned char *) &tst;
Packit 423ecb
Packit 423ecb
    if (handlers != NULL) return;
Packit 423ecb
Packit 423ecb
    handlers = (xmlCharEncodingHandlerPtr *)
Packit 423ecb
        xmlMalloc(MAX_ENCODING_HANDLERS * sizeof(xmlCharEncodingHandlerPtr));
Packit 423ecb
Packit 423ecb
    if (*ptr == 0x12) xmlLittleEndian = 0;
Packit 423ecb
    else if (*ptr == 0x34) xmlLittleEndian = 1;
Packit 423ecb
    else {
Packit 423ecb
        xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
Packit 423ecb
	               "Odd problem at endianness detection\n", NULL);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    if (handlers == NULL) {
Packit 423ecb
        xmlEncodingErrMemory("xmlInitCharEncodingHandlers : out of memory !\n");
Packit 423ecb
	return;
Packit 423ecb
    }
Packit 423ecb
    xmlNewCharEncodingHandler("UTF-8", UTF8ToUTF8, UTF8ToUTF8);
Packit 423ecb
#ifdef LIBXML_OUTPUT_ENABLED
Packit 423ecb
    xmlUTF16LEHandler =
Packit 423ecb
          xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE);
Packit 423ecb
    xmlUTF16BEHandler =
Packit 423ecb
          xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, UTF8ToUTF16BE);
Packit 423ecb
    xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, UTF8ToUTF16);
Packit 423ecb
    xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1);
Packit 423ecb
    xmlNewCharEncodingHandler("ASCII", asciiToUTF8, UTF8Toascii);
Packit 423ecb
    xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, UTF8Toascii);
Packit 423ecb
#ifdef LIBXML_HTML_ENABLED
Packit 423ecb
    xmlNewCharEncodingHandler("HTML", NULL, UTF8ToHtml);
Packit 423ecb
#endif
Packit 423ecb
#else
Packit 423ecb
    xmlUTF16LEHandler =
Packit 423ecb
          xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, NULL);
Packit 423ecb
    xmlUTF16BEHandler =
Packit 423ecb
          xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, NULL);
Packit 423ecb
    xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, NULL);
Packit 423ecb
    xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, NULL);
Packit 423ecb
    xmlNewCharEncodingHandler("ASCII", asciiToUTF8, NULL);
Packit 423ecb
    xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, NULL);
Packit 423ecb
#endif /* LIBXML_OUTPUT_ENABLED */
Packit 423ecb
#if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
Packit 423ecb
#ifdef LIBXML_ISO8859X_ENABLED
Packit 423ecb
    xmlRegisterCharEncodingHandlersISO8859x ();
Packit 423ecb
#endif
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCleanupCharEncodingHandlers:
Packit 423ecb
 *
Packit 423ecb
 * Cleanup the memory allocated for the char encoding support, it
Packit 423ecb
 * unregisters all the encoding handlers and the aliases.
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlCleanupCharEncodingHandlers(void) {
Packit 423ecb
    xmlCleanupEncodingAliases();
Packit 423ecb
Packit 423ecb
    if (handlers == NULL) return;
Packit 423ecb
Packit 423ecb
    for (;nbCharEncodingHandler > 0;) {
Packit 423ecb
        nbCharEncodingHandler--;
Packit 423ecb
	if (handlers[nbCharEncodingHandler] != NULL) {
Packit 423ecb
	    if (handlers[nbCharEncodingHandler]->name != NULL)
Packit 423ecb
		xmlFree(handlers[nbCharEncodingHandler]->name);
Packit 423ecb
	    xmlFree(handlers[nbCharEncodingHandler]);
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    xmlFree(handlers);
Packit 423ecb
    handlers = NULL;
Packit 423ecb
    nbCharEncodingHandler = 0;
Packit 423ecb
    xmlDefaultCharEncodingHandler = NULL;
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlRegisterCharEncodingHandler:
Packit 423ecb
 * @handler:  the xmlCharEncodingHandlerPtr handler block
Packit 423ecb
 *
Packit 423ecb
 * Register the char encoding handler, surprising, isn't it ?
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
Packit 423ecb
    if (handlers == NULL) xmlInitCharEncodingHandlers();
Packit 423ecb
    if ((handler == NULL) || (handlers == NULL)) {
Packit 423ecb
        xmlEncodingErr(XML_I18N_NO_HANDLER,
Packit 423ecb
		"xmlRegisterCharEncodingHandler: NULL handler !\n", NULL);
Packit 423ecb
	return;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) {
Packit 423ecb
        xmlEncodingErr(XML_I18N_EXCESS_HANDLER,
Packit 423ecb
	"xmlRegisterCharEncodingHandler: Too many handler registered, see %s\n",
Packit 423ecb
	               "MAX_ENCODING_HANDLERS");
Packit 423ecb
	return;
Packit 423ecb
    }
Packit 423ecb
    handlers[nbCharEncodingHandler++] = handler;
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlGetCharEncodingHandler:
Packit 423ecb
 * @enc:  an xmlCharEncoding value.
Packit 423ecb
 *
Packit 423ecb
 * Search in the registered set the handler able to read/write that encoding.
Packit 423ecb
 *
Packit 423ecb
 * Returns the handler or NULL if not found
Packit 423ecb
 */
Packit 423ecb
xmlCharEncodingHandlerPtr
Packit 423ecb
xmlGetCharEncodingHandler(xmlCharEncoding enc) {
Packit 423ecb
    xmlCharEncodingHandlerPtr handler;
Packit 423ecb
Packit 423ecb
    if (handlers == NULL) xmlInitCharEncodingHandlers();
Packit 423ecb
    switch (enc) {
Packit 423ecb
        case XML_CHAR_ENCODING_ERROR:
Packit 423ecb
	    return(NULL);
Packit 423ecb
        case XML_CHAR_ENCODING_NONE:
Packit 423ecb
	    return(NULL);
Packit 423ecb
        case XML_CHAR_ENCODING_UTF8:
Packit 423ecb
	    return(NULL);
Packit 423ecb
        case XML_CHAR_ENCODING_UTF16LE:
Packit 423ecb
	    return(xmlUTF16LEHandler);
Packit 423ecb
        case XML_CHAR_ENCODING_UTF16BE:
Packit 423ecb
	    return(xmlUTF16BEHandler);
Packit 423ecb
        case XML_CHAR_ENCODING_EBCDIC:
Packit 423ecb
            handler = xmlFindCharEncodingHandler("EBCDIC");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("ebcdic");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("EBCDIC-US");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("IBM-037");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_UCS4BE:
Packit 423ecb
            handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("UCS-4");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("UCS4");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_UCS4LE:
Packit 423ecb
            handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("UCS-4");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("UCS4");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_UCS4_2143:
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_UCS4_3412:
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_UCS2:
Packit 423ecb
            handler = xmlFindCharEncodingHandler("ISO-10646-UCS-2");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("UCS-2");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("UCS2");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
Packit 423ecb
	    /*
Packit 423ecb
	     * We used to keep ISO Latin encodings native in the
Packit 423ecb
	     * generated data. This led to so many problems that
Packit 423ecb
	     * this has been removed. One can still change this
Packit 423ecb
	     * back by registering no-ops encoders for those
Packit 423ecb
	     */
Packit 423ecb
        case XML_CHAR_ENCODING_8859_1:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-1");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_8859_2:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-2");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_8859_3:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-3");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_8859_4:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-4");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_8859_5:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-5");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_8859_6:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-6");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_8859_7:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-7");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_8859_8:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-8");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_8859_9:
Packit 423ecb
	    handler = xmlFindCharEncodingHandler("ISO-8859-9");
Packit 423ecb
	    if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
Packit 423ecb
Packit 423ecb
        case XML_CHAR_ENCODING_2022_JP:
Packit 423ecb
            handler = xmlFindCharEncodingHandler("ISO-2022-JP");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_SHIFT_JIS:
Packit 423ecb
            handler = xmlFindCharEncodingHandler("SHIFT-JIS");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("SHIFT_JIS");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
            handler = xmlFindCharEncodingHandler("Shift_JIS");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
        case XML_CHAR_ENCODING_EUC_JP:
Packit 423ecb
            handler = xmlFindCharEncodingHandler("EUC-JP");
Packit 423ecb
            if (handler != NULL) return(handler);
Packit 423ecb
	    break;
Packit 423ecb
	default:
Packit 423ecb
	    break;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
	    "No handler found for encoding %d\n", enc);
Packit 423ecb
#endif
Packit 423ecb
    return(NULL);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlFindCharEncodingHandler:
Packit 423ecb
 * @name:  a string describing the char encoding.
Packit 423ecb
 *
Packit 423ecb
 * Search in the registered set the handler able to read/write that encoding.
Packit 423ecb
 *
Packit 423ecb
 * Returns the handler or NULL if not found
Packit 423ecb
 */
Packit 423ecb
xmlCharEncodingHandlerPtr
Packit 423ecb
xmlFindCharEncodingHandler(const char *name) {
Packit 423ecb
    const char *nalias;
Packit 423ecb
    const char *norig;
Packit 423ecb
    xmlCharEncoding alias;
Packit 423ecb
#ifdef LIBXML_ICONV_ENABLED
Packit 423ecb
    xmlCharEncodingHandlerPtr enc;
Packit 423ecb
    iconv_t icv_in, icv_out;
Packit 423ecb
#endif /* LIBXML_ICONV_ENABLED */
Packit 423ecb
#ifdef LIBXML_ICU_ENABLED
Packit 423ecb
    xmlCharEncodingHandlerPtr encu;
Packit 423ecb
    uconv_t *ucv_in, *ucv_out;
Packit 423ecb
#endif /* LIBXML_ICU_ENABLED */
Packit 423ecb
    char upper[100];
Packit 423ecb
    int i;
Packit 423ecb
Packit 423ecb
    if (handlers == NULL) xmlInitCharEncodingHandlers();
Packit 423ecb
    if (name == NULL) return(xmlDefaultCharEncodingHandler);
Packit 423ecb
    if (name[0] == 0) return(xmlDefaultCharEncodingHandler);
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Do the alias resolution
Packit 423ecb
     */
Packit 423ecb
    norig = name;
Packit 423ecb
    nalias = xmlGetEncodingAlias(name);
Packit 423ecb
    if (nalias != NULL)
Packit 423ecb
	name = nalias;
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Check first for directly registered encoding names
Packit 423ecb
     */
Packit 423ecb
    for (i = 0;i < 99;i++) {
Packit 423ecb
        upper[i] = toupper(name[i]);
Packit 423ecb
	if (upper[i] == 0) break;
Packit 423ecb
    }
Packit 423ecb
    upper[i] = 0;
Packit 423ecb
Packit 423ecb
    if (handlers != NULL) {
Packit 423ecb
        for (i = 0;i < nbCharEncodingHandler; i++) {
Packit 423ecb
            if (!strcmp(upper, handlers[i]->name)) {
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
                xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "Found registered handler for encoding %s\n", name);
Packit 423ecb
#endif
Packit 423ecb
                return(handlers[i]);
Packit 423ecb
            }
Packit 423ecb
        }
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_ICONV_ENABLED
Packit 423ecb
    /* check whether iconv can handle this */
Packit 423ecb
    icv_in = iconv_open("UTF-8", name);
Packit 423ecb
    icv_out = iconv_open(name, "UTF-8");
Packit 423ecb
    if (icv_in == (iconv_t) -1) {
Packit 423ecb
        icv_in = iconv_open("UTF-8", upper);
Packit 423ecb
    }
Packit 423ecb
    if (icv_out == (iconv_t) -1) {
Packit 423ecb
	icv_out = iconv_open(upper, "UTF-8");
Packit 423ecb
    }
Packit 423ecb
    if ((icv_in != (iconv_t) -1) && (icv_out != (iconv_t) -1)) {
Packit 423ecb
	    enc = (xmlCharEncodingHandlerPtr)
Packit 423ecb
	          xmlMalloc(sizeof(xmlCharEncodingHandler));
Packit 423ecb
	    if (enc == NULL) {
Packit 423ecb
	        iconv_close(icv_in);
Packit 423ecb
	        iconv_close(icv_out);
Packit 423ecb
		return(NULL);
Packit 423ecb
	    }
Packit 423ecb
            memset(enc, 0, sizeof(xmlCharEncodingHandler));
Packit 423ecb
	    enc->name = xmlMemStrdup(name);
Packit 423ecb
	    enc->input = NULL;
Packit 423ecb
	    enc->output = NULL;
Packit 423ecb
	    enc->iconv_in = icv_in;
Packit 423ecb
	    enc->iconv_out = icv_out;
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "Found iconv handler for encoding %s\n", name);
Packit 423ecb
#endif
Packit 423ecb
	    return enc;
Packit 423ecb
    } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
Packit 423ecb
	    xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
Packit 423ecb
		    "iconv : problems with filters for '%s'\n", name);
Packit 423ecb
    }
Packit 423ecb
#endif /* LIBXML_ICONV_ENABLED */
Packit 423ecb
#ifdef LIBXML_ICU_ENABLED
Packit 423ecb
    /* check whether icu can handle this */
Packit 423ecb
    ucv_in = openIcuConverter(name, 1);
Packit 423ecb
    ucv_out = openIcuConverter(name, 0);
Packit 423ecb
    if (ucv_in != NULL && ucv_out != NULL) {
Packit 423ecb
	    encu = (xmlCharEncodingHandlerPtr)
Packit 423ecb
	           xmlMalloc(sizeof(xmlCharEncodingHandler));
Packit 423ecb
	    if (encu == NULL) {
Packit 423ecb
                closeIcuConverter(ucv_in);
Packit 423ecb
                closeIcuConverter(ucv_out);
Packit 423ecb
		return(NULL);
Packit 423ecb
	    }
Packit 423ecb
            memset(encu, 0, sizeof(xmlCharEncodingHandler));
Packit 423ecb
	    encu->name = xmlMemStrdup(name);
Packit 423ecb
	    encu->input = NULL;
Packit 423ecb
	    encu->output = NULL;
Packit 423ecb
	    encu->uconv_in = ucv_in;
Packit 423ecb
	    encu->uconv_out = ucv_out;
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "Found ICU converter handler for encoding %s\n", name);
Packit 423ecb
#endif
Packit 423ecb
	    return encu;
Packit 423ecb
    } else if (ucv_in != NULL || ucv_out != NULL) {
Packit 423ecb
            closeIcuConverter(ucv_in);
Packit 423ecb
            closeIcuConverter(ucv_out);
Packit 423ecb
	    xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
Packit 423ecb
		    "ICU converter : problems with filters for '%s'\n", name);
Packit 423ecb
    }
Packit 423ecb
#endif /* LIBXML_ICU_ENABLED */
Packit 423ecb
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
	    "No handler found for encoding %s\n", name);
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Fallback using the canonical names
Packit 423ecb
     */
Packit 423ecb
    alias = xmlParseCharEncoding(norig);
Packit 423ecb
    if (alias != XML_CHAR_ENCODING_ERROR) {
Packit 423ecb
        const char* canon;
Packit 423ecb
        canon = xmlGetCharEncodingName(alias);
Packit 423ecb
        if ((canon != NULL) && (strcmp(name, canon))) {
Packit 423ecb
	    return(xmlFindCharEncodingHandler(canon));
Packit 423ecb
        }
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    /* If "none of the above", give up */
Packit 423ecb
    return(NULL);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *		ICONV based generic conversion functions		*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_ICONV_ENABLED
Packit 423ecb
/**
Packit 423ecb
 * xmlIconvWrapper:
Packit 423ecb
 * @cd:		iconv converter data structure
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of ISO Latin 1 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 if success, or
Packit 423ecb
 *     -1 by lack of space, or
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 *     -3 if there the last byte can't form a single output char.
Packit 423ecb
 *
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 *     as the return value is positive, else unpredictable.
Packit 423ecb
 * The value of @outlen after return is the number of ocetes consumed.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
Packit 423ecb
                const unsigned char *in, int *inlen) {
Packit 423ecb
    size_t icv_inlen, icv_outlen;
Packit 423ecb
    const char *icv_in = (const char *) in;
Packit 423ecb
    char *icv_out = (char *) out;
Packit 423ecb
    int ret;
Packit 423ecb
Packit 423ecb
    if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
Packit 423ecb
        if (outlen != NULL) *outlen = 0;
Packit 423ecb
        return(-1);
Packit 423ecb
    }
Packit 423ecb
    icv_inlen = *inlen;
Packit 423ecb
    icv_outlen = *outlen;
Packit 423ecb
    ret = iconv(cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
Packit 423ecb
    *inlen -= icv_inlen;
Packit 423ecb
    *outlen -= icv_outlen;
Packit 423ecb
    if ((icv_inlen != 0) || (ret == -1)) {
Packit 423ecb
#ifdef EILSEQ
Packit 423ecb
        if (errno == EILSEQ) {
Packit 423ecb
            return -2;
Packit 423ecb
        } else
Packit 423ecb
#endif
Packit 423ecb
#ifdef E2BIG
Packit 423ecb
        if (errno == E2BIG) {
Packit 423ecb
            return -1;
Packit 423ecb
        } else
Packit 423ecb
#endif
Packit 423ecb
#ifdef EINVAL
Packit 423ecb
        if (errno == EINVAL) {
Packit 423ecb
            return -3;
Packit 423ecb
        } else
Packit 423ecb
#endif
Packit 423ecb
        {
Packit 423ecb
            return -3;
Packit 423ecb
        }
Packit 423ecb
    }
Packit 423ecb
    return 0;
Packit 423ecb
}
Packit 423ecb
#endif /* LIBXML_ICONV_ENABLED */
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *		ICU based generic conversion functions		*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_ICU_ENABLED
Packit 423ecb
/**
Packit 423ecb
 * xmlUconvWrapper:
Packit 423ecb
 * @cd: ICU uconverter data structure
Packit 423ecb
 * @toUnicode : non-zero if toUnicode. 0 otherwise.
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of ISO Latin 1 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 if success, or
Packit 423ecb
 *     -1 by lack of space, or
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 *     -3 if there the last byte can't form a single output char.
Packit 423ecb
 *
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 *     as the return value is positive, else unpredictable.
Packit 423ecb
 * The value of @outlen after return is the number of ocetes consumed.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
Packit 423ecb
                const unsigned char *in, int *inlen) {
Packit 423ecb
    const char *ucv_in = (const char *) in;
Packit 423ecb
    char *ucv_out = (char *) out;
Packit 423ecb
    UErrorCode err = U_ZERO_ERROR;
Packit 423ecb
Packit 423ecb
    if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
Packit 423ecb
        if (outlen != NULL) *outlen = 0;
Packit 423ecb
        return(-1);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * TODO(jungshik)
Packit 423ecb
     * 1. is ucnv_convert(To|From)Algorithmic better?
Packit 423ecb
     * 2. had we better use an explicit pivot buffer?
Packit 423ecb
     * 3. error returned comes from 'fromUnicode' only even
Packit 423ecb
     *    when toUnicode is true !
Packit 423ecb
     */
Packit 423ecb
    if (toUnicode) {
Packit 423ecb
        /* encoding => UTF-16 => UTF-8 */
Packit 423ecb
        ucnv_convertEx(cd->utf8, cd->uconv, &ucv_out, ucv_out + *outlen,
Packit 423ecb
                       &ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL,
Packit 423ecb
                       0, TRUE, &err;;
Packit 423ecb
    } else {
Packit 423ecb
        /* UTF-8 => UTF-16 => encoding */
Packit 423ecb
        ucnv_convertEx(cd->uconv, cd->utf8, &ucv_out, ucv_out + *outlen,
Packit 423ecb
                       &ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL,
Packit 423ecb
                       0, TRUE, &err;;
Packit 423ecb
    }
Packit 423ecb
    *inlen = ucv_in - (const char*) in;
Packit 423ecb
    *outlen = ucv_out - (char *) out;
Packit 423ecb
    if (U_SUCCESS(err))
Packit 423ecb
        return 0;
Packit 423ecb
    if (err == U_BUFFER_OVERFLOW_ERROR)
Packit 423ecb
        return -1;
Packit 423ecb
    if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND)
Packit 423ecb
        return -2;
Packit 423ecb
    /* if (err == U_TRUNCATED_CHAR_FOUND) */
Packit 423ecb
    return -3;
Packit 423ecb
}
Packit 423ecb
#endif /* LIBXML_ICU_ENABLED */
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *		The real API used by libxml for on-the-fly conversion	*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
static int
Packit 423ecb
xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
Packit 423ecb
                 int *outlen, const unsigned char *in, int *inlen) {
Packit 423ecb
    int ret;
Packit 423ecb
Packit 423ecb
    if (handler->input != NULL) {
Packit 423ecb
        ret = handler->input(out, outlen, in, inlen);
Packit 423ecb
    }
Packit 423ecb
#ifdef LIBXML_ICONV_ENABLED
Packit 423ecb
    else if (handler->iconv_in != NULL) {
Packit 423ecb
        ret = xmlIconvWrapper(handler->iconv_in, out, outlen, in, inlen);
Packit 423ecb
    }
Packit 423ecb
#endif /* LIBXML_ICONV_ENABLED */
Packit 423ecb
#ifdef LIBXML_ICU_ENABLED
Packit 423ecb
    else if (handler->uconv_in != NULL) {
Packit 423ecb
        ret = xmlUconvWrapper(handler->uconv_in, 1, out, outlen, in, inlen);
Packit 423ecb
    }
Packit 423ecb
#endif /* LIBXML_ICU_ENABLED */
Packit 423ecb
    else {
Packit 423ecb
        *outlen = 0;
Packit 423ecb
        *inlen = 0;
Packit 423ecb
        ret = -2;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return(ret);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/* Returns -4 if no output function was found. */
Packit 423ecb
static int
Packit 423ecb
xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
Packit 423ecb
                  int *outlen, const unsigned char *in, int *inlen) {
Packit 423ecb
    int ret;
Packit 423ecb
Packit 423ecb
    if (handler->output != NULL) {
Packit 423ecb
        ret = handler->output(out, outlen, in, inlen);
Packit 423ecb
    }
Packit 423ecb
#ifdef LIBXML_ICONV_ENABLED
Packit 423ecb
    else if (handler->iconv_out != NULL) {
Packit 423ecb
        ret = xmlIconvWrapper(handler->iconv_out, out, outlen, in, inlen);
Packit 423ecb
    }
Packit 423ecb
#endif /* LIBXML_ICONV_ENABLED */
Packit 423ecb
#ifdef LIBXML_ICU_ENABLED
Packit 423ecb
    else if (handler->uconv_out != NULL) {
Packit 423ecb
        ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen);
Packit 423ecb
    }
Packit 423ecb
#endif /* LIBXML_ICU_ENABLED */
Packit 423ecb
    else {
Packit 423ecb
        *outlen = 0;
Packit 423ecb
        *inlen = 0;
Packit 423ecb
        ret = -4;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    return(ret);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCharEncFirstLineInt:
Packit 423ecb
 * @handler:	char enconding transformation data structure
Packit 423ecb
 * @out:  an xmlBuffer for the output.
Packit 423ecb
 * @in:  an xmlBuffer for the input
Packit 423ecb
 * @len:  number of bytes to convert for the first line, or -1
Packit 423ecb
 *
Packit 423ecb
 * Front-end for the encoding handler input function, but handle only
Packit 423ecb
 * the very first line, i.e. limit itself to 45 chars.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of byte written if success, or
Packit 423ecb
 *     -1 general error
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
Packit 423ecb
                       xmlBufferPtr in, int len) {
Packit 423ecb
    int ret;
Packit 423ecb
    int written;
Packit 423ecb
    int toconv;
Packit 423ecb
Packit 423ecb
    if (handler == NULL) return(-1);
Packit 423ecb
    if (out == NULL) return(-1);
Packit 423ecb
    if (in == NULL) return(-1);
Packit 423ecb
Packit 423ecb
    /* calculate space available */
Packit 423ecb
    written = out->size - out->use - 1; /* count '\0' */
Packit 423ecb
    toconv = in->use;
Packit 423ecb
    /*
Packit 423ecb
     * echo '' | wc -c => 38
Packit 423ecb
     * 45 chars should be sufficient to reach the end of the encoding
Packit 423ecb
     * declaration without going too far inside the document content.
Packit 423ecb
     * on UTF-16 this means 90bytes, on UCS4 this means 180
Packit 423ecb
     * The actual value depending on guessed encoding is passed as @len
Packit 423ecb
     * if provided
Packit 423ecb
     */
Packit 423ecb
    if (len >= 0) {
Packit 423ecb
        if (toconv > len)
Packit 423ecb
            toconv = len;
Packit 423ecb
    } else {
Packit 423ecb
        if (toconv > 180)
Packit 423ecb
            toconv = 180;
Packit 423ecb
    }
Packit 423ecb
    if (toconv * 2 >= written) {
Packit 423ecb
        xmlBufferGrow(out, toconv * 2);
Packit 423ecb
	written = out->size - out->use - 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
Packit 423ecb
                           in->content, &toconv);
Packit 423ecb
    xmlBufferShrink(in, toconv);
Packit 423ecb
    out->use += written;
Packit 423ecb
    out->content[out->use] = 0;
Packit 423ecb
    if (ret == -1) ret = -3;
Packit 423ecb
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
    switch (ret) {
Packit 423ecb
        case 0:
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "converted %d bytes to %d bytes of input\n",
Packit 423ecb
	            toconv, written);
Packit 423ecb
	    break;
Packit 423ecb
        case -1:
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
Packit 423ecb
	            toconv, written, in->use);
Packit 423ecb
	    break;
Packit 423ecb
        case -2:
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "input conversion failed due to input error\n");
Packit 423ecb
	    break;
Packit 423ecb
        case -3:
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
Packit 423ecb
	            toconv, written, in->use);
Packit 423ecb
	    break;
Packit 423ecb
	default:
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,"Unknown input conversion failed %d\n", ret);
Packit 423ecb
    }
Packit 423ecb
#endif /* DEBUG_ENCODING */
Packit 423ecb
    /*
Packit 423ecb
     * Ignore when input buffer is not on a boundary
Packit 423ecb
     */
Packit 423ecb
    if (ret == -3) ret = 0;
Packit 423ecb
    if (ret == -1) ret = 0;
Packit 423ecb
    return(ret);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCharEncFirstLine:
Packit 423ecb
 * @handler:	char enconding transformation data structure
Packit 423ecb
 * @out:  an xmlBuffer for the output.
Packit 423ecb
 * @in:  an xmlBuffer for the input
Packit 423ecb
 *
Packit 423ecb
 * Front-end for the encoding handler input function, but handle only
Packit 423ecb
 * the very first line, i.e. limit itself to 45 chars.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of byte written if success, or
Packit 423ecb
 *     -1 general error
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
Packit 423ecb
                 xmlBufferPtr in) {
Packit 423ecb
    return(xmlCharEncFirstLineInt(handler, out, in, -1));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCharEncFirstLineInput:
Packit 423ecb
 * @input: a parser input buffer
Packit 423ecb
 * @len:  number of bytes to convert for the first line, or -1
Packit 423ecb
 *
Packit 423ecb
 * Front-end for the encoding handler input function, but handle only
Packit 423ecb
 * the very first line. Point is that this is based on autodetection
Packit 423ecb
 * of the encoding and once that first line is converted we may find
Packit 423ecb
 * out that a different decoder is needed to process the input.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of byte written if success, or
Packit 423ecb
 *     -1 general error
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
Packit 423ecb
{
Packit 423ecb
    int ret;
Packit 423ecb
    size_t written;
Packit 423ecb
    size_t toconv;
Packit 423ecb
    int c_in;
Packit 423ecb
    int c_out;
Packit 423ecb
    xmlBufPtr in;
Packit 423ecb
    xmlBufPtr out;
Packit 423ecb
Packit 423ecb
    if ((input == NULL) || (input->encoder == NULL) ||
Packit 423ecb
        (input->buffer == NULL) || (input->raw == NULL))
Packit 423ecb
        return (-1);
Packit 423ecb
    out = input->buffer;
Packit 423ecb
    in = input->raw;
Packit 423ecb
Packit 423ecb
    toconv = xmlBufUse(in);
Packit 423ecb
    if (toconv == 0)
Packit 423ecb
        return (0);
Packit 423ecb
    written = xmlBufAvail(out) - 1; /* count '\0' */
Packit 423ecb
    /*
Packit 423ecb
     * echo '' | wc -c => 38
Packit 423ecb
     * 45 chars should be sufficient to reach the end of the encoding
Packit 423ecb
     * declaration without going too far inside the document content.
Packit 423ecb
     * on UTF-16 this means 90bytes, on UCS4 this means 180
Packit 423ecb
     * The actual value depending on guessed encoding is passed as @len
Packit 423ecb
     * if provided
Packit 423ecb
     */
Packit 423ecb
    if (len >= 0) {
Packit 423ecb
        if (toconv > (unsigned int) len)
Packit 423ecb
            toconv = len;
Packit 423ecb
    } else {
Packit 423ecb
        if (toconv > 180)
Packit 423ecb
            toconv = 180;
Packit 423ecb
    }
Packit 423ecb
    if (toconv * 2 >= written) {
Packit 423ecb
        xmlBufGrow(out, toconv * 2);
Packit 423ecb
        written = xmlBufAvail(out) - 1;
Packit 423ecb
    }
Packit 423ecb
    if (written > 360)
Packit 423ecb
        written = 360;
Packit 423ecb
Packit 423ecb
    c_in = toconv;
Packit 423ecb
    c_out = written;
Packit 423ecb
    ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
Packit 423ecb
                           xmlBufContent(in), &c_in);
Packit 423ecb
    xmlBufShrink(in, c_in);
Packit 423ecb
    xmlBufAddLen(out, c_out);
Packit 423ecb
    if (ret == -1)
Packit 423ecb
        ret = -3;
Packit 423ecb
Packit 423ecb
    switch (ret) {
Packit 423ecb
        case 0:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                            "converted %d bytes to %d bytes of input\n",
Packit 423ecb
                            c_in, c_out);
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -1:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                         "converted %d bytes to %d bytes of input, %d left\n",
Packit 423ecb
                            c_in, c_out, (int)xmlBufUse(in));
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -3:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "converted %d bytes to %d bytes of input, %d left\n",
Packit 423ecb
                            c_in, c_out, (int)xmlBufUse(in));
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -2: {
Packit 423ecb
            char buf[50];
Packit 423ecb
            const xmlChar *content = xmlBufContent(in);
Packit 423ecb
Packit 423ecb
	    snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
Packit 423ecb
		     content[0], content[1],
Packit 423ecb
		     content[2], content[3]);
Packit 423ecb
	    buf[49] = 0;
Packit 423ecb
	    xmlEncodingErr(XML_I18N_CONV_FAILED,
Packit 423ecb
		    "input conversion failed due to input error, bytes %s\n",
Packit 423ecb
		           buf);
Packit 423ecb
        }
Packit 423ecb
    }
Packit 423ecb
    /*
Packit 423ecb
     * Ignore when input buffer is not on a boundary
Packit 423ecb
     */
Packit 423ecb
    if (ret == -3) ret = 0;
Packit 423ecb
    if (ret == -1) ret = 0;
Packit 423ecb
    return(ret);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCharEncInput:
Packit 423ecb
 * @input: a parser input buffer
Packit 423ecb
 * @flush: try to flush all the raw buffer
Packit 423ecb
 *
Packit 423ecb
 * Generic front-end for the encoding handler on parser input
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of byte written if success, or
Packit 423ecb
 *     -1 general error
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
Packit 423ecb
{
Packit 423ecb
    int ret;
Packit 423ecb
    size_t written;
Packit 423ecb
    size_t toconv;
Packit 423ecb
    int c_in;
Packit 423ecb
    int c_out;
Packit 423ecb
    xmlBufPtr in;
Packit 423ecb
    xmlBufPtr out;
Packit 423ecb
Packit 423ecb
    if ((input == NULL) || (input->encoder == NULL) ||
Packit 423ecb
        (input->buffer == NULL) || (input->raw == NULL))
Packit 423ecb
        return (-1);
Packit 423ecb
    out = input->buffer;
Packit 423ecb
    in = input->raw;
Packit 423ecb
Packit 423ecb
    toconv = xmlBufUse(in);
Packit 423ecb
    if (toconv == 0)
Packit 423ecb
        return (0);
Packit 423ecb
    if ((toconv > 64 * 1024) && (flush == 0))
Packit 423ecb
        toconv = 64 * 1024;
Packit 423ecb
    written = xmlBufAvail(out);
Packit 423ecb
    if (written > 0)
Packit 423ecb
        written--; /* count '\0' */
Packit 423ecb
    if (toconv * 2 >= written) {
Packit 423ecb
        xmlBufGrow(out, toconv * 2);
Packit 423ecb
        written = xmlBufAvail(out);
Packit 423ecb
        if (written > 0)
Packit 423ecb
            written--; /* count '\0' */
Packit 423ecb
    }
Packit 423ecb
    if ((written > 128 * 1024) && (flush == 0))
Packit 423ecb
        written = 128 * 1024;
Packit 423ecb
Packit 423ecb
    c_in = toconv;
Packit 423ecb
    c_out = written;
Packit 423ecb
    ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
Packit 423ecb
                           xmlBufContent(in), &c_in);
Packit 423ecb
    xmlBufShrink(in, c_in);
Packit 423ecb
    xmlBufAddLen(out, c_out);
Packit 423ecb
    if (ret == -1)
Packit 423ecb
        ret = -3;
Packit 423ecb
Packit 423ecb
    switch (ret) {
Packit 423ecb
        case 0:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                            "converted %d bytes to %d bytes of input\n",
Packit 423ecb
                            c_in, c_out);
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -1:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                         "converted %d bytes to %d bytes of input, %d left\n",
Packit 423ecb
                            c_in, c_out, (int)xmlBufUse(in));
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -3:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "converted %d bytes to %d bytes of input, %d left\n",
Packit 423ecb
                            c_in, c_out, (int)xmlBufUse(in));
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -2: {
Packit 423ecb
            char buf[50];
Packit 423ecb
            const xmlChar *content = xmlBufContent(in);
Packit 423ecb
Packit 423ecb
	    snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
Packit 423ecb
		     content[0], content[1],
Packit 423ecb
		     content[2], content[3]);
Packit 423ecb
	    buf[49] = 0;
Packit 423ecb
	    xmlEncodingErr(XML_I18N_CONV_FAILED,
Packit 423ecb
		    "input conversion failed due to input error, bytes %s\n",
Packit 423ecb
		           buf);
Packit 423ecb
        }
Packit 423ecb
    }
Packit 423ecb
    /*
Packit 423ecb
     * Ignore when input buffer is not on a boundary
Packit 423ecb
     */
Packit 423ecb
    if (ret == -3)
Packit 423ecb
        ret = 0;
Packit 423ecb
    return (c_out? c_out : ret);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCharEncInFunc:
Packit 423ecb
 * @handler:	char encoding transformation data structure
Packit 423ecb
 * @out:  an xmlBuffer for the output.
Packit 423ecb
 * @in:  an xmlBuffer for the input
Packit 423ecb
 *
Packit 423ecb
 * Generic front-end for the encoding handler input function
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of byte written if success, or
Packit 423ecb
 *     -1 general error
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
Packit 423ecb
                 xmlBufferPtr in)
Packit 423ecb
{
Packit 423ecb
    int ret;
Packit 423ecb
    int written;
Packit 423ecb
    int toconv;
Packit 423ecb
Packit 423ecb
    if (handler == NULL)
Packit 423ecb
        return (-1);
Packit 423ecb
    if (out == NULL)
Packit 423ecb
        return (-1);
Packit 423ecb
    if (in == NULL)
Packit 423ecb
        return (-1);
Packit 423ecb
Packit 423ecb
    toconv = in->use;
Packit 423ecb
    if (toconv == 0)
Packit 423ecb
        return (0);
Packit 423ecb
    written = out->size - out->use -1; /* count '\0' */
Packit 423ecb
    if (toconv * 2 >= written) {
Packit 423ecb
        xmlBufferGrow(out, out->size + toconv * 2);
Packit 423ecb
        written = out->size - out->use - 1;
Packit 423ecb
    }
Packit 423ecb
    ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
Packit 423ecb
                           in->content, &toconv);
Packit 423ecb
    xmlBufferShrink(in, toconv);
Packit 423ecb
    out->use += written;
Packit 423ecb
    out->content[out->use] = 0;
Packit 423ecb
    if (ret == -1)
Packit 423ecb
        ret = -3;
Packit 423ecb
Packit 423ecb
    switch (ret) {
Packit 423ecb
        case 0:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                            "converted %d bytes to %d bytes of input\n",
Packit 423ecb
                            toconv, written);
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -1:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                         "converted %d bytes to %d bytes of input, %d left\n",
Packit 423ecb
                            toconv, written, in->use);
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -3:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                        "converted %d bytes to %d bytes of input, %d left\n",
Packit 423ecb
                            toconv, written, in->use);
Packit 423ecb
#endif
Packit 423ecb
            break;
Packit 423ecb
        case -2: {
Packit 423ecb
            char buf[50];
Packit 423ecb
Packit 423ecb
	    snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
Packit 423ecb
		     in->content[0], in->content[1],
Packit 423ecb
		     in->content[2], in->content[3]);
Packit 423ecb
	    buf[49] = 0;
Packit 423ecb
	    xmlEncodingErr(XML_I18N_CONV_FAILED,
Packit 423ecb
		    "input conversion failed due to input error, bytes %s\n",
Packit 423ecb
		           buf);
Packit 423ecb
        }
Packit 423ecb
    }
Packit 423ecb
    /*
Packit 423ecb
     * Ignore when input buffer is not on a boundary
Packit 423ecb
     */
Packit 423ecb
    if (ret == -3)
Packit 423ecb
        ret = 0;
Packit 423ecb
    return (written? written : ret);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
#ifdef LIBXML_OUTPUT_ENABLED
Packit 423ecb
/**
Packit 423ecb
 * xmlCharEncOutput:
Packit 423ecb
 * @output: a parser output buffer
Packit 423ecb
 * @init: is this an initialization call without data
Packit 423ecb
 *
Packit 423ecb
 * Generic front-end for the encoding handler on parser output
Packit 423ecb
 * a first call with @init == 1 has to be made first to initiate the
Packit 423ecb
 * output in case of non-stateless encoding needing to initiate their
Packit 423ecb
 * state or the output (like the BOM in UTF16).
Packit 423ecb
 * In case of UTF8 sequence conversion errors for the given encoder,
Packit 423ecb
 * the content will be automatically remapped to a CharRef sequence.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of byte written if success, or
Packit 423ecb
 *     -1 general error
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCharEncOutput(xmlOutputBufferPtr output, int init)
Packit 423ecb
{
Packit 423ecb
    int ret;
Packit 423ecb
    size_t written;
Packit 423ecb
    size_t writtentot = 0;
Packit 423ecb
    size_t toconv;
Packit 423ecb
    int c_in;
Packit 423ecb
    int c_out;
Packit 423ecb
    xmlBufPtr in;
Packit 423ecb
    xmlBufPtr out;
Packit 423ecb
Packit 423ecb
    if ((output == NULL) || (output->encoder == NULL) ||
Packit 423ecb
        (output->buffer == NULL) || (output->conv == NULL))
Packit 423ecb
        return (-1);
Packit 423ecb
    out = output->conv;
Packit 423ecb
    in = output->buffer;
Packit 423ecb
Packit 423ecb
retry:
Packit 423ecb
Packit 423ecb
    written = xmlBufAvail(out);
Packit 423ecb
    if (written > 0)
Packit 423ecb
        written--; /* count '\0' */
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * First specific handling of the initialization call
Packit 423ecb
     */
Packit 423ecb
    if (init) {
Packit 423ecb
        c_in = 0;
Packit 423ecb
        c_out = written;
Packit 423ecb
        /* TODO: Check return value. */
Packit 423ecb
        xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
Packit 423ecb
                          NULL, &c_in);
Packit 423ecb
        xmlBufAddLen(out, c_out);
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
	xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		"initialized encoder\n");
Packit 423ecb
#endif
Packit 423ecb
        return(0);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Conversion itself.
Packit 423ecb
     */
Packit 423ecb
    toconv = xmlBufUse(in);
Packit 423ecb
    if (toconv == 0)
Packit 423ecb
        return (0);
Packit 423ecb
    if (toconv > 64 * 1024)
Packit 423ecb
        toconv = 64 * 1024;
Packit 423ecb
    if (toconv * 4 >= written) {
Packit 423ecb
        xmlBufGrow(out, toconv * 4);
Packit 423ecb
        written = xmlBufAvail(out) - 1;
Packit 423ecb
    }
Packit 423ecb
    if (written > 256 * 1024)
Packit 423ecb
        written = 256 * 1024;
Packit 423ecb
Packit 423ecb
    c_in = toconv;
Packit 423ecb
    c_out = written;
Packit 423ecb
    ret = xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
Packit 423ecb
                            xmlBufContent(in), &c_in);
Packit 423ecb
    xmlBufShrink(in, c_in);
Packit 423ecb
    xmlBufAddLen(out, c_out);
Packit 423ecb
    writtentot += c_out;
Packit 423ecb
    if (ret == -1) {
Packit 423ecb
        if (c_out > 0) {
Packit 423ecb
            /* Can be a limitation of iconv or uconv */
Packit 423ecb
            goto retry;
Packit 423ecb
        }
Packit 423ecb
        ret = -3;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    if (ret >= 0) output += ret;
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Attempt to handle error cases
Packit 423ecb
     */
Packit 423ecb
    switch (ret) {
Packit 423ecb
        case 0:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "converted %d bytes to %d bytes of output\n",
Packit 423ecb
	            c_in, c_out);
Packit 423ecb
#endif
Packit 423ecb
	    break;
Packit 423ecb
        case -1:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "output conversion failed by lack of space\n");
Packit 423ecb
#endif
Packit 423ecb
	    break;
Packit 423ecb
        case -3:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
Packit 423ecb
	            c_in, c_out, (int) xmlBufUse(in));
Packit 423ecb
#endif
Packit 423ecb
	    break;
Packit 423ecb
        case -4:
Packit 423ecb
            xmlEncodingErr(XML_I18N_NO_OUTPUT,
Packit 423ecb
                           "xmlCharEncOutFunc: no output function !\n", NULL);
Packit 423ecb
            ret = -1;
Packit 423ecb
            break;
Packit 423ecb
        case -2: {
Packit 423ecb
	    xmlChar charref[20];
Packit 423ecb
	    int len = (int) xmlBufUse(in);
Packit 423ecb
            xmlChar *content = xmlBufContent(in);
Packit 423ecb
	    int cur, charrefLen;
Packit 423ecb
Packit 423ecb
	    cur = xmlGetUTF8Char(content, &len;;
Packit 423ecb
	    if (cur <= 0)
Packit 423ecb
                break;
Packit 423ecb
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                    "handling output conversion error\n");
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                    "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
Packit 423ecb
                    content[0], content[1],
Packit 423ecb
                    content[2], content[3]);
Packit 423ecb
#endif
Packit 423ecb
            /*
Packit 423ecb
             * Removes the UTF8 sequence, and replace it by a charref
Packit 423ecb
             * and continue the transcoding phase, hoping the error
Packit 423ecb
             * did not mangle the encoder state.
Packit 423ecb
             */
Packit 423ecb
            charrefLen = snprintf((char *) &charref[0], sizeof(charref),
Packit 423ecb
                             "&#%d;", cur);
Packit 423ecb
            xmlBufShrink(in, len);
Packit 423ecb
            xmlBufGrow(out, charrefLen * 4);
Packit 423ecb
            c_out = xmlBufAvail(out) - 1;
Packit 423ecb
            c_in = charrefLen;
Packit 423ecb
            ret = xmlEncOutputChunk(output->encoder, xmlBufEnd(out), &c_out,
Packit 423ecb
                                    charref, &c_in);
Packit 423ecb
Packit 423ecb
	    if ((ret < 0) || (c_in != charrefLen)) {
Packit 423ecb
		char buf[50];
Packit 423ecb
Packit 423ecb
		snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
Packit 423ecb
			 content[0], content[1],
Packit 423ecb
			 content[2], content[3]);
Packit 423ecb
		buf[49] = 0;
Packit 423ecb
		xmlEncodingErr(XML_I18N_CONV_FAILED,
Packit 423ecb
		    "output conversion failed due to conv error, bytes %s\n",
Packit 423ecb
			       buf);
Packit 423ecb
		if (xmlBufGetAllocationScheme(in) != XML_BUFFER_ALLOC_IMMUTABLE)
Packit 423ecb
		    content[0] = ' ';
Packit 423ecb
                break;
Packit 423ecb
	    }
Packit 423ecb
Packit 423ecb
            xmlBufAddLen(out, c_out);
Packit 423ecb
            writtentot += c_out;
Packit 423ecb
            goto retry;
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    return(ret);
Packit 423ecb
}
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCharEncOutFunc:
Packit 423ecb
 * @handler:	char enconding transformation data structure
Packit 423ecb
 * @out:  an xmlBuffer for the output.
Packit 423ecb
 * @in:  an xmlBuffer for the input
Packit 423ecb
 *
Packit 423ecb
 * Generic front-end for the encoding handler output function
Packit 423ecb
 * a first call with @in == NULL has to be made firs to initiate the
Packit 423ecb
 * output in case of non-stateless encoding needing to initiate their
Packit 423ecb
 * state or the output (like the BOM in UTF16).
Packit 423ecb
 * In case of UTF8 sequence conversion errors for the given encoder,
Packit 423ecb
 * the content will be automatically remapped to a CharRef sequence.
Packit 423ecb
 *
Packit 423ecb
 * Returns the number of byte written if success, or
Packit 423ecb
 *     -1 general error
Packit 423ecb
 *     -2 if the transcoding fails (for *in is not valid utf8 string or
Packit 423ecb
 *        the result of transformation can't fit into the encoding we want), or
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
Packit 423ecb
                  xmlBufferPtr in) {
Packit 423ecb
    int ret;
Packit 423ecb
    int written;
Packit 423ecb
    int writtentot = 0;
Packit 423ecb
    int toconv;
Packit 423ecb
    int output = 0;
Packit 423ecb
Packit 423ecb
    if (handler == NULL) return(-1);
Packit 423ecb
    if (out == NULL) return(-1);
Packit 423ecb
Packit 423ecb
retry:
Packit 423ecb
Packit 423ecb
    written = out->size - out->use;
Packit 423ecb
Packit 423ecb
    if (written > 0)
Packit 423ecb
	written--; /* Gennady: count '/0' */
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * First specific handling of in = NULL, i.e. the initialization call
Packit 423ecb
     */
Packit 423ecb
    if (in == NULL) {
Packit 423ecb
        toconv = 0;
Packit 423ecb
        /* TODO: Check return value. */
Packit 423ecb
        xmlEncOutputChunk(handler, &out->content[out->use], &written,
Packit 423ecb
                          NULL, &toconv);
Packit 423ecb
        out->use += written;
Packit 423ecb
        out->content[out->use] = 0;
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
	xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		"initialized encoder\n");
Packit 423ecb
#endif
Packit 423ecb
        return(0);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Conversion itself.
Packit 423ecb
     */
Packit 423ecb
    toconv = in->use;
Packit 423ecb
    if (toconv == 0)
Packit 423ecb
	return(0);
Packit 423ecb
    if (toconv * 4 >= written) {
Packit 423ecb
        xmlBufferGrow(out, toconv * 4);
Packit 423ecb
	written = out->size - out->use - 1;
Packit 423ecb
    }
Packit 423ecb
    ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
Packit 423ecb
                            in->content, &toconv);
Packit 423ecb
    xmlBufferShrink(in, toconv);
Packit 423ecb
    out->use += written;
Packit 423ecb
    writtentot += written;
Packit 423ecb
    out->content[out->use] = 0;
Packit 423ecb
    if (ret == -1) {
Packit 423ecb
        if (written > 0) {
Packit 423ecb
            /* Can be a limitation of iconv or uconv */
Packit 423ecb
            goto retry;
Packit 423ecb
        }
Packit 423ecb
        ret = -3;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    if (ret >= 0) output += ret;
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Attempt to handle error cases
Packit 423ecb
     */
Packit 423ecb
    switch (ret) {
Packit 423ecb
        case 0:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "converted %d bytes to %d bytes of output\n",
Packit 423ecb
	            toconv, written);
Packit 423ecb
#endif
Packit 423ecb
	    break;
Packit 423ecb
        case -1:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "output conversion failed by lack of space\n");
Packit 423ecb
#endif
Packit 423ecb
	    break;
Packit 423ecb
        case -3:
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
Packit 423ecb
	            toconv, written, in->use);
Packit 423ecb
#endif
Packit 423ecb
	    break;
Packit 423ecb
        case -4:
Packit 423ecb
	    xmlEncodingErr(XML_I18N_NO_OUTPUT,
Packit 423ecb
		           "xmlCharEncOutFunc: no output function !\n", NULL);
Packit 423ecb
	    ret = -1;
Packit 423ecb
            break;
Packit 423ecb
        case -2: {
Packit 423ecb
	    xmlChar charref[20];
Packit 423ecb
	    int len = in->use;
Packit 423ecb
	    const xmlChar *utf = (const xmlChar *) in->content;
Packit 423ecb
	    int cur, charrefLen;
Packit 423ecb
Packit 423ecb
	    cur = xmlGetUTF8Char(utf, &len;;
Packit 423ecb
	    if (cur <= 0)
Packit 423ecb
                break;
Packit 423ecb
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                    "handling output conversion error\n");
Packit 423ecb
            xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
                    "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
Packit 423ecb
                    in->content[0], in->content[1],
Packit 423ecb
                    in->content[2], in->content[3]);
Packit 423ecb
#endif
Packit 423ecb
            /*
Packit 423ecb
             * Removes the UTF8 sequence, and replace it by a charref
Packit 423ecb
             * and continue the transcoding phase, hoping the error
Packit 423ecb
             * did not mangle the encoder state.
Packit 423ecb
             */
Packit 423ecb
            charrefLen = snprintf((char *) &charref[0], sizeof(charref),
Packit 423ecb
                             "&#%d;", cur);
Packit 423ecb
            xmlBufferShrink(in, len);
Packit 423ecb
            xmlBufferGrow(out, charrefLen * 4);
Packit 423ecb
	    written = out->size - out->use - 1;
Packit 423ecb
            toconv = charrefLen;
Packit 423ecb
            ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
Packit 423ecb
                                    charref, &toconv);
Packit 423ecb
Packit 423ecb
	    if ((ret < 0) || (toconv != charrefLen)) {
Packit 423ecb
		char buf[50];
Packit 423ecb
Packit 423ecb
		snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
Packit 423ecb
			 in->content[0], in->content[1],
Packit 423ecb
			 in->content[2], in->content[3]);
Packit 423ecb
		buf[49] = 0;
Packit 423ecb
		xmlEncodingErr(XML_I18N_CONV_FAILED,
Packit 423ecb
		    "output conversion failed due to conv error, bytes %s\n",
Packit 423ecb
			       buf);
Packit 423ecb
		if (in->alloc != XML_BUFFER_ALLOC_IMMUTABLE)
Packit 423ecb
		    in->content[0] = ' ';
Packit 423ecb
	        break;
Packit 423ecb
	    }
Packit 423ecb
Packit 423ecb
            out->use += written;
Packit 423ecb
            writtentot += written;
Packit 423ecb
            out->content[out->use] = 0;
Packit 423ecb
            goto retry;
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    return(ret);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCharEncCloseFunc:
Packit 423ecb
 * @handler:	char enconding transformation data structure
Packit 423ecb
 *
Packit 423ecb
 * Generic front-end for encoding handler close function
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 if success, or -1 in case of error
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
Packit 423ecb
    int ret = 0;
Packit 423ecb
    int tofree = 0;
Packit 423ecb
    int i, handler_in_list = 0;
Packit 423ecb
Packit 423ecb
    if (handler == NULL) return(-1);
Packit 423ecb
    if (handler->name == NULL) return(-1);
Packit 423ecb
    if (handlers != NULL) {
Packit 423ecb
        for (i = 0;i < nbCharEncodingHandler; i++) {
Packit 423ecb
            if (handler == handlers[i]) {
Packit 423ecb
	        handler_in_list = 1;
Packit 423ecb
		break;
Packit 423ecb
	    }
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
#ifdef LIBXML_ICONV_ENABLED
Packit 423ecb
    /*
Packit 423ecb
     * Iconv handlers can be used only once, free the whole block.
Packit 423ecb
     * and the associated icon resources.
Packit 423ecb
     */
Packit 423ecb
    if ((handler_in_list == 0) &&
Packit 423ecb
        ((handler->iconv_out != NULL) || (handler->iconv_in != NULL))) {
Packit 423ecb
        tofree = 1;
Packit 423ecb
	if (handler->iconv_out != NULL) {
Packit 423ecb
	    if (iconv_close(handler->iconv_out))
Packit 423ecb
		ret = -1;
Packit 423ecb
	    handler->iconv_out = NULL;
Packit 423ecb
	}
Packit 423ecb
	if (handler->iconv_in != NULL) {
Packit 423ecb
	    if (iconv_close(handler->iconv_in))
Packit 423ecb
		ret = -1;
Packit 423ecb
	    handler->iconv_in = NULL;
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
#endif /* LIBXML_ICONV_ENABLED */
Packit 423ecb
#ifdef LIBXML_ICU_ENABLED
Packit 423ecb
    if ((handler_in_list == 0) &&
Packit 423ecb
        ((handler->uconv_out != NULL) || (handler->uconv_in != NULL))) {
Packit 423ecb
        tofree = 1;
Packit 423ecb
	if (handler->uconv_out != NULL) {
Packit 423ecb
	    closeIcuConverter(handler->uconv_out);
Packit 423ecb
	    handler->uconv_out = NULL;
Packit 423ecb
	}
Packit 423ecb
	if (handler->uconv_in != NULL) {
Packit 423ecb
	    closeIcuConverter(handler->uconv_in);
Packit 423ecb
	    handler->uconv_in = NULL;
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
#endif
Packit 423ecb
    if (tofree) {
Packit 423ecb
        /* free up only dynamic handlers iconv/uconv */
Packit 423ecb
        if (handler->name != NULL)
Packit 423ecb
            xmlFree(handler->name);
Packit 423ecb
        handler->name = NULL;
Packit 423ecb
        xmlFree(handler);
Packit 423ecb
    }
Packit 423ecb
#ifdef DEBUG_ENCODING
Packit 423ecb
    if (ret)
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		"failed to close the encoding handler\n");
Packit 423ecb
    else
Packit 423ecb
        xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		"closed the encoding handler\n");
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
    return(ret);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlByteConsumed:
Packit 423ecb
 * @ctxt: an XML parser context
Packit 423ecb
 *
Packit 423ecb
 * This function provides the current index of the parser relative
Packit 423ecb
 * to the start of the current entity. This function is computed in
Packit 423ecb
 * bytes from the beginning starting at zero and finishing at the
Packit 423ecb
 * size in byte of the file if parsing a file. The function is
Packit 423ecb
 * of constant cost if the input is UTF-8 but can be costly if run
Packit 423ecb
 * on non-UTF-8 input.
Packit 423ecb
 *
Packit 423ecb
 * Returns the index in bytes from the beginning of the entity or -1
Packit 423ecb
 *         in case the index could not be computed.
Packit 423ecb
 */
Packit 423ecb
long
Packit 423ecb
xmlByteConsumed(xmlParserCtxtPtr ctxt) {
Packit 423ecb
    xmlParserInputPtr in;
Packit 423ecb
Packit 423ecb
    if (ctxt == NULL) return(-1);
Packit 423ecb
    in = ctxt->input;
Packit 423ecb
    if (in == NULL)  return(-1);
Packit 423ecb
    if ((in->buf != NULL) && (in->buf->encoder != NULL)) {
Packit 423ecb
        unsigned int unused = 0;
Packit 423ecb
	xmlCharEncodingHandler * handler = in->buf->encoder;
Packit 423ecb
        /*
Packit 423ecb
	 * Encoding conversion, compute the number of unused original
Packit 423ecb
	 * bytes from the input not consumed and substract that from
Packit 423ecb
	 * the raw consumed value, this is not a cheap operation
Packit 423ecb
	 */
Packit 423ecb
        if (in->end - in->cur > 0) {
Packit 423ecb
	    unsigned char convbuf[32000];
Packit 423ecb
	    const unsigned char *cur = (const unsigned char *)in->cur;
Packit 423ecb
	    int toconv = in->end - in->cur, written = 32000;
Packit 423ecb
Packit 423ecb
	    int ret;
Packit 423ecb
Packit 423ecb
            do {
Packit 423ecb
                toconv = in->end - cur;
Packit 423ecb
                written = 32000;
Packit 423ecb
                ret = xmlEncOutputChunk(handler, &convbuf[0], &written,
Packit 423ecb
                                        cur, &toconv);
Packit 423ecb
                if (ret < 0) {
Packit 423ecb
                    if (written > 0)
Packit 423ecb
                        ret = -2;
Packit 423ecb
                    else
Packit 423ecb
                        return(-1);
Packit 423ecb
                }
Packit 423ecb
                unused += written;
Packit 423ecb
                cur += toconv;
Packit 423ecb
            } while (ret == -2);
Packit 423ecb
	}
Packit 423ecb
	if (in->buf->rawconsumed < unused)
Packit 423ecb
	    return(-1);
Packit 423ecb
	return(in->buf->rawconsumed - unused);
Packit 423ecb
    }
Packit 423ecb
    return(in->consumed + (in->cur - in->base));
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
#if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
Packit 423ecb
#ifdef LIBXML_ISO8859X_ENABLED
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * UTF8ToISO8859x:
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of UTF-8 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 * @xlattable: the 2-level transcoding table
Packit 423ecb
 *
Packit 423ecb
 * Take a block of UTF-8 chars in and try to convert it to an ISO 8859-*
Packit 423ecb
 * block of chars out.
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 *     as the return value is positive, else unpredictable.
Packit 423ecb
 * The value of @outlen after return is the number of ocetes consumed.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
UTF8ToISO8859x(unsigned char* out, int *outlen,
Packit 423ecb
              const unsigned char* in, int *inlen,
Packit 423ecb
              unsigned char const *xlattable) {
Packit 423ecb
    const unsigned char* outstart = out;
Packit 423ecb
    const unsigned char* inend;
Packit 423ecb
    const unsigned char* instart = in;
Packit 423ecb
    const unsigned char* processed = in;
Packit 423ecb
Packit 423ecb
    if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
Packit 423ecb
        (xlattable == NULL))
Packit 423ecb
	return(-1);
Packit 423ecb
    if (in == NULL) {
Packit 423ecb
        /*
Packit 423ecb
        * initialization nothing to do
Packit 423ecb
        */
Packit 423ecb
        *outlen = 0;
Packit 423ecb
        *inlen = 0;
Packit 423ecb
        return(0);
Packit 423ecb
    }
Packit 423ecb
    inend = in + (*inlen);
Packit 423ecb
    while (in < inend) {
Packit 423ecb
        unsigned char d = *in++;
Packit 423ecb
        if  (d < 0x80)  {
Packit 423ecb
            *out++ = d;
Packit 423ecb
        } else if (d < 0xC0) {
Packit 423ecb
            /* trailing byte in leading position */
Packit 423ecb
            *outlen = out - outstart;
Packit 423ecb
            *inlen = processed - instart;
Packit 423ecb
            return(-2);
Packit 423ecb
        } else if (d < 0xE0) {
Packit 423ecb
            unsigned char c;
Packit 423ecb
            if (!(in < inend)) {
Packit 423ecb
                /* trailing byte not in input buffer */
Packit 423ecb
                *outlen = out - outstart;
Packit 423ecb
                *inlen = processed - instart;
Packit 423ecb
                return(-3);
Packit 423ecb
            }
Packit 423ecb
            c = *in++;
Packit 423ecb
            if ((c & 0xC0) != 0x80) {
Packit 423ecb
                /* not a trailing byte */
Packit 423ecb
                *outlen = out - outstart;
Packit 423ecb
                *inlen = processed - instart;
Packit 423ecb
                return(-2);
Packit 423ecb
            }
Packit 423ecb
            c = c & 0x3F;
Packit 423ecb
            d = d & 0x1F;
Packit 423ecb
            d = xlattable [48 + c + xlattable [d] * 64];
Packit 423ecb
            if (d == 0) {
Packit 423ecb
                /* not in character set */
Packit 423ecb
                *outlen = out - outstart;
Packit 423ecb
                *inlen = processed - instart;
Packit 423ecb
                return(-2);
Packit 423ecb
            }
Packit 423ecb
            *out++ = d;
Packit 423ecb
        } else if (d < 0xF0) {
Packit 423ecb
            unsigned char c1;
Packit 423ecb
            unsigned char c2;
Packit 423ecb
            if (!(in < inend - 1)) {
Packit 423ecb
                /* trailing bytes not in input buffer */
Packit 423ecb
                *outlen = out - outstart;
Packit 423ecb
                *inlen = processed - instart;
Packit 423ecb
                return(-3);
Packit 423ecb
            }
Packit 423ecb
            c1 = *in++;
Packit 423ecb
            if ((c1 & 0xC0) != 0x80) {
Packit 423ecb
                /* not a trailing byte (c1) */
Packit 423ecb
                *outlen = out - outstart;
Packit 423ecb
                *inlen = processed - instart;
Packit 423ecb
                return(-2);
Packit 423ecb
            }
Packit 423ecb
            c2 = *in++;
Packit 423ecb
            if ((c2 & 0xC0) != 0x80) {
Packit 423ecb
                /* not a trailing byte (c2) */
Packit 423ecb
                *outlen = out - outstart;
Packit 423ecb
                *inlen = processed - instart;
Packit 423ecb
                return(-2);
Packit 423ecb
            }
Packit 423ecb
            c1 = c1 & 0x3F;
Packit 423ecb
            c2 = c2 & 0x3F;
Packit 423ecb
	    d = d & 0x0F;
Packit 423ecb
	    d = xlattable [48 + c2 + xlattable [48 + c1 +
Packit 423ecb
			xlattable [32 + d] * 64] * 64];
Packit 423ecb
            if (d == 0) {
Packit 423ecb
                /* not in character set */
Packit 423ecb
                *outlen = out - outstart;
Packit 423ecb
                *inlen = processed - instart;
Packit 423ecb
                return(-2);
Packit 423ecb
            }
Packit 423ecb
            *out++ = d;
Packit 423ecb
        } else {
Packit 423ecb
            /* cannot transcode >= U+010000 */
Packit 423ecb
            *outlen = out - outstart;
Packit 423ecb
            *inlen = processed - instart;
Packit 423ecb
            return(-2);
Packit 423ecb
        }
Packit 423ecb
        processed = in;
Packit 423ecb
    }
Packit 423ecb
    *outlen = out - outstart;
Packit 423ecb
    *inlen = processed - instart;
Packit 423ecb
    return(*outlen);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * ISO8859xToUTF8
Packit 423ecb
 * @out:  a pointer to an array of bytes to store the result
Packit 423ecb
 * @outlen:  the length of @out
Packit 423ecb
 * @in:  a pointer to an array of ISO Latin 1 chars
Packit 423ecb
 * @inlen:  the length of @in
Packit 423ecb
 *
Packit 423ecb
 * Take a block of ISO 8859-* chars in and try to convert it to an UTF-8
Packit 423ecb
 * block of chars out.
Packit 423ecb
 * Returns 0 if success, or -1 otherwise
Packit 423ecb
 * The value of @inlen after return is the number of octets consumed
Packit 423ecb
 * The value of @outlen after return is the number of ocetes produced.
Packit 423ecb
 */
Packit 423ecb
static int
Packit 423ecb
ISO8859xToUTF8(unsigned char* out, int *outlen,
Packit 423ecb
              const unsigned char* in, int *inlen,
Packit 423ecb
              unsigned short const *unicodetable) {
Packit 423ecb
    unsigned char* outstart = out;
Packit 423ecb
    unsigned char* outend;
Packit 423ecb
    const unsigned char* instart = in;
Packit 423ecb
    const unsigned char* inend;
Packit 423ecb
    const unsigned char* instop;
Packit 423ecb
    unsigned int c;
Packit 423ecb
Packit 423ecb
    if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
Packit 423ecb
        (in == NULL) || (unicodetable == NULL))
Packit 423ecb
	return(-1);
Packit 423ecb
    outend = out + *outlen;
Packit 423ecb
    inend = in + *inlen;
Packit 423ecb
    instop = inend;
Packit 423ecb
Packit 423ecb
    while ((in < inend) && (out < outend - 2)) {
Packit 423ecb
        if (*in >= 0x80) {
Packit 423ecb
            c = unicodetable [*in - 0x80];
Packit 423ecb
            if (c == 0) {
Packit 423ecb
                /* undefined code point */
Packit 423ecb
                *outlen = out - outstart;
Packit 423ecb
                *inlen = in - instart;
Packit 423ecb
                return (-1);
Packit 423ecb
            }
Packit 423ecb
            if (c < 0x800) {
Packit 423ecb
                *out++ = ((c >>  6) & 0x1F) | 0xC0;
Packit 423ecb
                *out++ = (c & 0x3F) | 0x80;
Packit 423ecb
            } else {
Packit 423ecb
                *out++ = ((c >>  12) & 0x0F) | 0xE0;
Packit 423ecb
                *out++ = ((c >>  6) & 0x3F) | 0x80;
Packit 423ecb
                *out++ = (c & 0x3F) | 0x80;
Packit 423ecb
            }
Packit 423ecb
            ++in;
Packit 423ecb
        }
Packit 423ecb
        if (instop - in > outend - out) instop = in + (outend - out);
Packit 423ecb
        while ((*in < 0x80) && (in < instop)) {
Packit 423ecb
            *out++ = *in++;
Packit 423ecb
        }
Packit 423ecb
    }
Packit 423ecb
    if ((in < inend) && (out < outend) && (*in < 0x80)) {
Packit 423ecb
        *out++ =  *in++;
Packit 423ecb
    }
Packit 423ecb
    if ((in < inend) && (out < outend) && (*in < 0x80)) {
Packit 423ecb
        *out++ =  *in++;
Packit 423ecb
    }
Packit 423ecb
    *outlen = out - outstart;
Packit 423ecb
    *inlen = in - instart;
Packit 423ecb
    return (*outlen);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 * Lookup tables for ISO-8859-2..ISO-8859-16 transcoding                *
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_2 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7,
Packit 423ecb
    0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
Packit 423ecb
    0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7,
Packit 423ecb
    0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
Packit 423ecb
    0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7,
Packit 423ecb
    0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
Packit 423ecb
    0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7,
Packit 423ecb
    0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
Packit 423ecb
    0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7,
Packit 423ecb
    0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
Packit 423ecb
    0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7,
Packit 423ecb
    0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_2 [48 + 6 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x05\x02\x04\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\x00\xa4\x00\x00\xa7\xa8\x00\x00\x00\x00\xad\x00\x00"
Packit 423ecb
    "\xb0\x00\x00\x00\xb4\x00\x00\x00\xb8\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xc3\xe3\xa1\xb1\xc6\xe6\x00\x00\x00\x00\xc8\xe8\xcf\xef"
Packit 423ecb
    "\xd0\xf0\x00\x00\x00\x00\x00\x00\xca\xea\xcc\xec\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc5\xe5\x00\x00\xa5\xb5\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\xb7\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\xa2\xff\x00\xb2\x00\xbd\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\xa3\xb3\xd1\xf1\x00\x00\xd2\xf2\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xd5\xf5\x00\x00\xc0\xe0\x00\x00\xd8\xf8\xa6\xb6\x00\x00\xaa\xba"
Packit 423ecb
    "\xa9\xb9\xde\xfe\xab\xbb\x00\x00\x00\x00\x00\x00\x00\x00\xd9\xf9"
Packit 423ecb
    "\xdb\xfb\x00\x00\x00\x00\x00\x00\x00\xac\xbc\xaf\xbf\xae\xbe\x00"
Packit 423ecb
    "\x00\xc1\xc2\x00\xc4\x00\x00\xc7\x00\xc9\x00\xcb\x00\xcd\xce\x00"
Packit 423ecb
    "\x00\x00\x00\xd3\xd4\x00\xd6\xd7\x00\x00\xda\x00\xdc\xdd\x00\xdf"
Packit 423ecb
    "\x00\xe1\xe2\x00\xe4\x00\x00\xe7\x00\xe9\x00\xeb\x00\xed\xee\x00"
Packit 423ecb
    "\x00\x00\x00\xf3\xf4\x00\xf6\xf7\x00\x00\xfa\x00\xfc\xfd\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_3 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7,
Packit 423ecb
    0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b,
Packit 423ecb
    0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7,
Packit 423ecb
    0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c,
Packit 423ecb
    0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7,
Packit 423ecb
    0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
Packit 423ecb
    0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7,
Packit 423ecb
    0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df,
Packit 423ecb
    0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7,
Packit 423ecb
    0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
Packit 423ecb
    0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7,
Packit 423ecb
    0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_3 [48 + 7 * 64] = {
Packit 423ecb
    "\x04\x00\x01\x06\x02\x05\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\xa3\xa4\x00\x00\xa7\xa8\x00\x00\x00\x00\xad\x00\x00"
Packit 423ecb
    "\xb0\x00\xb2\xb3\xb4\xb5\x00\xb7\xb8\x00\x00\x00\x00\xbd\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\xc6\xe6\xc5\xe5\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd8\xf8\xab\xbb"
Packit 423ecb
    "\xd5\xf5\x00\x00\xa6\xb6\xa1\xb1\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xa9\xb9\x00\x00\xac\xbc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\xa2\xff\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xfe\xaa\xba"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdd\xfd\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaf\xbf\x00\x00\x00"
Packit 423ecb
    "\xc0\xc1\xc2\x00\xc4\x00\x00\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\x00\xd1\xd2\xd3\xd4\x00\xd6\xd7\x00\xd9\xda\xdb\xdc\x00\x00\xdf"
Packit 423ecb
    "\xe0\xe1\xe2\x00\xe4\x00\x00\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\x00\xf1\xf2\xf3\xf4\x00\xf6\xf7\x00\xf9\xfa\xfb\xfc\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_4 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7,
Packit 423ecb
    0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af,
Packit 423ecb
    0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7,
Packit 423ecb
    0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b,
Packit 423ecb
    0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
Packit 423ecb
    0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a,
Packit 423ecb
    0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
Packit 423ecb
    0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df,
Packit 423ecb
    0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
Packit 423ecb
    0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b,
Packit 423ecb
    0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
Packit 423ecb
    0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_4 [48 + 6 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x05\x02\x03\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\x00\xa4\x00\x00\xa7\xa8\x00\x00\x00\x00\xad\x00\xaf"
Packit 423ecb
    "\xb0\x00\x00\x00\xb4\x00\x00\x00\xb8\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xc0\xe0\x00\x00\xa1\xb1\x00\x00\x00\x00\x00\x00\xc8\xe8\x00\x00"
Packit 423ecb
    "\xd0\xf0\xaa\xba\x00\x00\xcc\xec\xca\xea\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xab\xbb\x00\x00\x00\x00\xa5\xb5\xcf\xef\x00\x00\xc7\xe7"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\xd3\xf3\xa2\x00\x00\xa6\xb6\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\xd1\xf1\x00\x00\x00\xbd\xbf\xd2\xf2\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\xa3\xb3\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xa9\xb9\x00\x00\x00\x00\xac\xbc\xdd\xfd\xde\xfe\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xd9\xf9\x00\x00\x00\x00\x00\x00\x00\x00\x00\xae\xbe\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\xb7\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\xb2\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\xc1\xc2\xc3\xc4\xc5\xc6\x00\x00\xc9\x00\xcb\x00\xcd\xce\x00"
Packit 423ecb
    "\x00\x00\x00\x00\xd4\xd5\xd6\xd7\xd8\x00\xda\xdb\xdc\x00\x00\xdf"
Packit 423ecb
    "\x00\xe1\xe2\xe3\xe4\xe5\xe6\x00\x00\xe9\x00\xeb\x00\xed\xee\x00"
Packit 423ecb
    "\x00\x00\x00\x00\xf4\xf5\xf6\xf7\xf8\x00\xfa\xfb\xfc\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_5 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
Packit 423ecb
    0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f,
Packit 423ecb
    0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
Packit 423ecb
    0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
Packit 423ecb
    0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
Packit 423ecb
    0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
Packit 423ecb
    0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
Packit 423ecb
    0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
Packit 423ecb
    0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
Packit 423ecb
    0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
Packit 423ecb
    0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
Packit 423ecb
    0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_5 [48 + 6 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\x00\x00\x00\x00\xfd\x00\x00\x00\x00\x00\xad\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\x00\xae\xaf"
Packit 423ecb
    "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
Packit 423ecb
    "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
Packit 423ecb
    "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\x00\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\x00\xfe\xff"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\xf0\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_6 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0000, 0x0000, 0x0000, 0x00a4, 0x0000, 0x0000, 0x0000,
Packit 423ecb
    0x0000, 0x0000, 0x0000, 0x0000, 0x060c, 0x00ad, 0x0000, 0x0000,
Packit 423ecb
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Packit 423ecb
    0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f,
Packit 423ecb
    0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
Packit 423ecb
    0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
Packit 423ecb
    0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
Packit 423ecb
    0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Packit 423ecb
    0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
Packit 423ecb
    0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
Packit 423ecb
    0x0650, 0x0651, 0x0652, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Packit 423ecb
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_6 [48 + 5 * 64] = {
Packit 423ecb
    "\x02\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x03\x04\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\x00\xa4\x00\x00\x00\x00\x00\x00\x00\x00\xad\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xac\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbb\x00\x00\x00\xbf"
Packit 423ecb
    "\x00\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\xf0\xf1\xf2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_7 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x2018, 0x2019, 0x00a3, 0x0000, 0x0000, 0x00a6, 0x00a7,
Packit 423ecb
    0x00a8, 0x00a9, 0x0000, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015,
Packit 423ecb
    0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7,
Packit 423ecb
    0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f,
Packit 423ecb
    0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
Packit 423ecb
    0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
Packit 423ecb
    0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
Packit 423ecb
    0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
Packit 423ecb
    0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
Packit 423ecb
    0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
Packit 423ecb
    0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
Packit 423ecb
    0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_7 [48 + 7 * 64] = {
Packit 423ecb
    "\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x06"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\xa3\x00\x00\xa6\xa7\xa8\xa9\x00\xab\xac\xad\x00\x00"
Packit 423ecb
    "\xb0\xb1\xb2\xb3\x00\x00\x00\xb7\x00\x00\x00\xbb\x00\xbd\x00\x00"
Packit 423ecb
    "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\xaf\x00\x00\xa1\xa2\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\xb4\xb5\xb6\x00\xb8\xb9\xba\x00\xbc\x00\xbe\xbf"
Packit 423ecb
    "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\xd0\xd1\x00\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
Packit 423ecb
    "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_8 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0000, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
Packit 423ecb
    0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
Packit 423ecb
    0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
Packit 423ecb
    0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x0000,
Packit 423ecb
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Packit 423ecb
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Packit 423ecb
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
Packit 423ecb
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2017,
Packit 423ecb
    0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
Packit 423ecb
    0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
Packit 423ecb
    0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
Packit 423ecb
    0x05e8, 0x05e9, 0x05ea, 0x0000, 0x0000, 0x200e, 0x200f, 0x0000,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_8 [48 + 7 * 64] = {
Packit 423ecb
    "\x02\x00\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\x00\xab\xac\xad\xae\xaf"
Packit 423ecb
    "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\x00\xbb\xbc\xbd\xbe\x00"
Packit 423ecb
    "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\xaa\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\xba\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfd\xfe"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\xdf\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_9 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
Packit 423ecb
    0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
Packit 423ecb
    0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
Packit 423ecb
    0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
Packit 423ecb
    0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
Packit 423ecb
    0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
Packit 423ecb
    0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
Packit 423ecb
    0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
Packit 423ecb
    0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
Packit 423ecb
    0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
Packit 423ecb
    0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
Packit 423ecb
    0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_9 [48 + 5 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x02\x03\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
Packit 423ecb
    "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
Packit 423ecb
    "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\x00\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\x00\x00\xdf"
Packit 423ecb
    "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\x00\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\x00\x00\xff"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\xf0"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xdd\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xde\xfe"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_10 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0104, 0x0112, 0x0122, 0x012a, 0x0128, 0x0136, 0x00a7,
Packit 423ecb
    0x013b, 0x0110, 0x0160, 0x0166, 0x017d, 0x00ad, 0x016a, 0x014a,
Packit 423ecb
    0x00b0, 0x0105, 0x0113, 0x0123, 0x012b, 0x0129, 0x0137, 0x00b7,
Packit 423ecb
    0x013c, 0x0111, 0x0161, 0x0167, 0x017e, 0x2015, 0x016b, 0x014b,
Packit 423ecb
    0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
Packit 423ecb
    0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x00cf,
Packit 423ecb
    0x00d0, 0x0145, 0x014c, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0168,
Packit 423ecb
    0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
Packit 423ecb
    0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
Packit 423ecb
    0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x00ef,
Packit 423ecb
    0x00f0, 0x0146, 0x014d, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0169,
Packit 423ecb
    0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_10 [48 + 7 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x06\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\x00\x00\x00\x00\xa7\x00\x00\x00\x00\x00\xad\x00\x00"
Packit 423ecb
    "\xb0\x00\x00\x00\x00\x00\x00\xb7\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xc0\xe0\x00\x00\xa1\xb1\x00\x00\x00\x00\x00\x00\xc8\xe8\x00\x00"
Packit 423ecb
    "\xa9\xb9\xa2\xb2\x00\x00\xcc\xec\xca\xea\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xa3\xb3\x00\x00\x00\x00\xa5\xb5\xa4\xb4\x00\x00\xc7\xe7"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\xa6\xb6\xff\x00\x00\xa8\xb8\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\xd1\xf1\x00\x00\x00\xaf\xbf\xd2\xf2\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xaa\xba\x00\x00\x00\x00\xab\xbb\xd7\xf7\xae\xbe\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xd9\xf9\x00\x00\x00\x00\x00\x00\x00\x00\x00\xac\xbc\x00"
Packit 423ecb
    "\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\xbd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\xc1\xc2\xc3\xc4\xc5\xc6\x00\x00\xc9\x00\xcb\x00\xcd\xce\xcf"
Packit 423ecb
    "\xd0\x00\x00\xd3\xd4\xd5\xd6\x00\xd8\x00\xda\xdb\xdc\xdd\xde\xdf"
Packit 423ecb
    "\x00\xe1\xe2\xe3\xe4\xe5\xe6\x00\x00\xe9\x00\xeb\x00\xed\xee\xef"
Packit 423ecb
    "\xf0\x00\x00\xf3\xf4\xf5\xf6\x00\xf8\x00\xfa\xfb\xfc\xfd\xfe\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_11 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
Packit 423ecb
    0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
Packit 423ecb
    0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
Packit 423ecb
    0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
Packit 423ecb
    0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
Packit 423ecb
    0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
Packit 423ecb
    0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
Packit 423ecb
    0x0e38, 0x0e39, 0x0e3a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0e3f,
Packit 423ecb
    0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
Packit 423ecb
    0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
Packit 423ecb
    0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
Packit 423ecb
    0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x0000, 0x0000, 0x0000, 0x0000,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_11 [48 + 6 * 64] = {
Packit 423ecb
    "\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x03\x05\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
Packit 423ecb
    "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
Packit 423ecb
    "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\x00\x00\x00\x00\xdf"
Packit 423ecb
    "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_13 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x201d, 0x00a2, 0x00a3, 0x00a4, 0x201e, 0x00a6, 0x00a7,
Packit 423ecb
    0x00d8, 0x00a9, 0x0156, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00c6,
Packit 423ecb
    0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x201c, 0x00b5, 0x00b6, 0x00b7,
Packit 423ecb
    0x00f8, 0x00b9, 0x0157, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00e6,
Packit 423ecb
    0x0104, 0x012e, 0x0100, 0x0106, 0x00c4, 0x00c5, 0x0118, 0x0112,
Packit 423ecb
    0x010c, 0x00c9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012a, 0x013b,
Packit 423ecb
    0x0160, 0x0143, 0x0145, 0x00d3, 0x014c, 0x00d5, 0x00d6, 0x00d7,
Packit 423ecb
    0x0172, 0x0141, 0x015a, 0x016a, 0x00dc, 0x017b, 0x017d, 0x00df,
Packit 423ecb
    0x0105, 0x012f, 0x0101, 0x0107, 0x00e4, 0x00e5, 0x0119, 0x0113,
Packit 423ecb
    0x010d, 0x00e9, 0x017a, 0x0117, 0x0123, 0x0137, 0x012b, 0x013c,
Packit 423ecb
    0x0161, 0x0144, 0x0146, 0x00f3, 0x014d, 0x00f5, 0x00f6, 0x00f7,
Packit 423ecb
    0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_13 [48 + 7 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x04\x06\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\xa2\xa3\xa4\x00\xa6\xa7\x00\xa9\x00\xab\xac\xad\xae\x00"
Packit 423ecb
    "\xb0\xb1\xb2\xb3\x00\xb5\xb6\xb7\x00\xb9\x00\xbb\xbc\xbd\xbe\x00"
Packit 423ecb
    "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00\x00\xb4\xa1\xa5\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\xc4\xc5\xaf\x00\x00\xc9\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\xd3\x00\xd5\xd6\xd7\xa8\x00\x00\x00\xdc\x00\x00\xdf"
Packit 423ecb
    "\x00\x00\x00\x00\xe4\xe5\xbf\x00\x00\xe9\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\xf3\x00\xf5\xf6\xf7\xb8\x00\x00\x00\xfc\x00\x00\x00"
Packit 423ecb
    "\x00\xd9\xf9\xd1\xf1\xd2\xf2\x00\x00\x00\x00\x00\xd4\xf4\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\xaa\xba\x00\x00\xda\xfa\x00\x00\x00\x00"
Packit 423ecb
    "\xd0\xf0\x00\x00\x00\x00\x00\x00\x00\x00\xdb\xfb\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xd8\xf8\x00\x00\x00\x00\x00\xca\xea\xdd\xfd\xde\xfe\x00"
Packit 423ecb
    "\xc2\xe2\x00\x00\xc0\xe0\xc3\xe3\x00\x00\x00\x00\xc8\xe8\x00\x00"
Packit 423ecb
    "\x00\x00\xc7\xe7\x00\x00\xcb\xeb\xc6\xe6\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xcc\xec\x00\x00\x00\x00\x00\x00\xce\xee\x00\x00\xc1\xe1"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\xcd\xed\x00\x00\x00\xcf\xef\x00\x00\x00"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_14 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7,
Packit 423ecb
    0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178,
Packit 423ecb
    0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56,
Packit 423ecb
    0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61,
Packit 423ecb
    0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
Packit 423ecb
    0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
Packit 423ecb
    0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a,
Packit 423ecb
    0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df,
Packit 423ecb
    0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
Packit 423ecb
    0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
Packit 423ecb
    0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b,
Packit 423ecb
    0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_14 [48 + 10 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x09\x04\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\xa3\x00\x00\x00\xa7\x00\xa9\x00\x00\x00\xad\xae\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\xb6\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x03\x08\x05\x06\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xa1\xa2\x00\x00\x00\x00\x00\x00\xa6\xab\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\xb1"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\xa5\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xb2\xb3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xa8\xb8\xaa\xba\xbd\xbe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xac\xbc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\xd0\xf0\xde\xfe\xaf\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xb4\xb5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\xb7\xb9\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xbb\xbf\x00\x00\x00\x00\x00\x00\x00\x00\xd7\xf7\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\x00\xd1\xd2\xd3\xd4\xd5\xd6\x00\xd8\xd9\xda\xdb\xdc\xdd\x00\xdf"
Packit 423ecb
    "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\x00\xf1\xf2\xf3\xf4\xf5\xf6\x00\xf8\xf9\xfa\xfb\xfc\xfd\x00\xff"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_15 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7,
Packit 423ecb
    0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
Packit 423ecb
    0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7,
Packit 423ecb
    0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
Packit 423ecb
    0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
Packit 423ecb
    0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
Packit 423ecb
    0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
Packit 423ecb
    0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
Packit 423ecb
    0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
Packit 423ecb
    0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
Packit 423ecb
    0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
Packit 423ecb
    0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_15 [48 + 6 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x05\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\xa1\xa2\xa3\x00\xa5\x00\xa7\x00\xa9\xaa\xab\xac\xad\xae\xaf"
Packit 423ecb
    "\xb0\xb1\xb2\xb3\x00\xb5\xb6\xb7\x00\xb9\xba\xbb\x00\x00\x00\xbf"
Packit 423ecb
    "\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xbc\xbd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xa6\xa8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\xbe\x00\x00\x00\x00\xb4\xb8\x00"
Packit 423ecb
    "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
Packit 423ecb
    "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned short const xmlunicodetable_ISO8859_16 [128] = {
Packit 423ecb
    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
Packit 423ecb
    0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
Packit 423ecb
    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
Packit 423ecb
    0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
Packit 423ecb
    0x00a0, 0x0104, 0x0105, 0x0141, 0x20ac, 0x201e, 0x0160, 0x00a7,
Packit 423ecb
    0x0161, 0x00a9, 0x0218, 0x00ab, 0x0179, 0x00ad, 0x017a, 0x017b,
Packit 423ecb
    0x00b0, 0x00b1, 0x010c, 0x0142, 0x017d, 0x201d, 0x00b6, 0x00b7,
Packit 423ecb
    0x017e, 0x010d, 0x0219, 0x00bb, 0x0152, 0x0153, 0x0178, 0x017c,
Packit 423ecb
    0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0106, 0x00c6, 0x00c7,
Packit 423ecb
    0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
Packit 423ecb
    0x0110, 0x0143, 0x00d2, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x015a,
Packit 423ecb
    0x0170, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0118, 0x021a, 0x00df,
Packit 423ecb
    0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x0107, 0x00e6, 0x00e7,
Packit 423ecb
    0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
Packit 423ecb
    0x0111, 0x0144, 0x00f2, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x015b,
Packit 423ecb
    0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff,
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
static unsigned char const xmltranscodetable_ISO8859_16 [48 + 9 * 64] = {
Packit 423ecb
    "\x00\x00\x01\x08\x02\x03\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
Packit 423ecb
    "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
Packit 423ecb
    "\xa0\x00\x00\x00\x00\x00\x00\xa7\x00\xa9\x00\xab\x00\xad\x00\x00"
Packit 423ecb
    "\xb0\xb1\x00\x00\x00\x00\xb6\xb7\x00\x00\x00\xbb\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\xc3\xe3\xa1\xa2\xc5\xe5\x00\x00\x00\x00\xb2\xb9\x00\x00"
Packit 423ecb
    "\xd0\xf0\x00\x00\x00\x00\x00\x00\xdd\xfd\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\xa3\xb3\xd1\xf1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xd5\xf5\xbc\xbd\x00\x00\x00\x00\x00\x00\xd7\xf7\x00\x00\x00\x00"
Packit 423ecb
    "\xa6\xa8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xd8\xf8\x00\x00\x00\x00\x00\x00\xbe\xac\xae\xaf\xbf\xb4\xb8\x00"
Packit 423ecb
    "\x06\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb5\xa5\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\xaa\xba\xde\xfe\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
Packit 423ecb
    "\xc0\xc1\xc2\x00\xc4\x00\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
Packit 423ecb
    "\x00\x00\xd2\xd3\xd4\x00\xd6\x00\x00\xd9\xda\xdb\xdc\x00\x00\xdf"
Packit 423ecb
    "\xe0\xe1\xe2\x00\xe4\x00\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
Packit 423ecb
    "\x00\x00\xf2\xf3\xf4\x00\xf6\x00\x00\xf9\xfa\xfb\xfc\x00\x00\xff"
Packit 423ecb
};
Packit 423ecb
Packit 423ecb
Packit 423ecb
/*
Packit 423ecb
 * auto-generated functions for ISO-8859-2 .. ISO-8859-16
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
static int ISO8859_2ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_2);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_2 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_2);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_3ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_3);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_3 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_3);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_4ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_4);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_4 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_4);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_5ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_5);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_5 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_5);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_6ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_6);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_6 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_6);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_7ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_7);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_7 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_7);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_8ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_8);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_8);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_9ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_9);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_9 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_9);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_10ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_10);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_10 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_10);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_11ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_11);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_11 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_11);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_13ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_13);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_13 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_13);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_14ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_14);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_14 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_14);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_15ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_15);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_15 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_15);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static int ISO8859_16ToUTF8 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return ISO8859xToUTF8 (out, outlen, in, inlen, xmlunicodetable_ISO8859_16);
Packit 423ecb
}
Packit 423ecb
static int UTF8ToISO8859_16 (unsigned char* out, int *outlen,
Packit 423ecb
    const unsigned char* in, int *inlen) {
Packit 423ecb
    return UTF8ToISO8859x (out, outlen, in, inlen, xmltranscodetable_ISO8859_16);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
static void
Packit 423ecb
xmlRegisterCharEncodingHandlersISO8859x (void) {
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-2", ISO8859_2ToUTF8, UTF8ToISO8859_2);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-3", ISO8859_3ToUTF8, UTF8ToISO8859_3);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-4", ISO8859_4ToUTF8, UTF8ToISO8859_4);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-5", ISO8859_5ToUTF8, UTF8ToISO8859_5);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-6", ISO8859_6ToUTF8, UTF8ToISO8859_6);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-7", ISO8859_7ToUTF8, UTF8ToISO8859_7);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-8", ISO8859_8ToUTF8, UTF8ToISO8859_8);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-9", ISO8859_9ToUTF8, UTF8ToISO8859_9);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-10", ISO8859_10ToUTF8, UTF8ToISO8859_10);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-11", ISO8859_11ToUTF8, UTF8ToISO8859_11);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-13", ISO8859_13ToUTF8, UTF8ToISO8859_13);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-14", ISO8859_14ToUTF8, UTF8ToISO8859_14);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-15", ISO8859_15ToUTF8, UTF8ToISO8859_15);
Packit 423ecb
    xmlNewCharEncodingHandler ("ISO-8859-16", ISO8859_16ToUTF8, UTF8ToISO8859_16);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
#endif
Packit 423ecb
#endif
Packit 423ecb
Packit 423ecb
#define bottom_encoding
Packit 423ecb
#include "elfgcchack.h"