ReactOS  0.4.14-dev-49-gfb4591c
encoding.c File Reference
#include "libxml.h"
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <stdlib.h>
#include <libxml/encoding.h>
#include <libxml/xmlmemory.h>
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
#include "buf.h"
#include "enc.h"
#include "elfgcchack.h"
Include dependency graph for encoding.c:

Go to the source code of this file.

Classes

struct  _xmlCharEncodingAlias
 

Macros

#define IN_LIBXML
 

Typedefs

typedef struct _xmlCharEncodingAlias xmlCharEncodingAlias
 
typedef xmlCharEncodingAliasxmlCharEncodingAliasPtr
 

Functions

static void xmlEncodingErrMemory (const char *extra)
 
static void LIBXML_ATTR_FORMAT (2, 0)
 
static int asciiToUTF8 (unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
 
int isolat1ToUTF8 (unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
 
static int UTF8ToUTF8 (unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
 
static int UTF16LEToUTF8 (unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
 
static int UTF16BEToUTF8 (unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
 
xmlCharEncoding xmlDetectCharEncoding (const unsigned char *in, int len)
 
void xmlCleanupEncodingAliases (void)
 
const charxmlGetEncodingAlias (const char *alias)
 
. Existing alias

will be overwritten.

Returns 0 in case of success, -1 in case of error

int xmlAddEncodingAlias (const char *name, const char *alias)
 
int xmlDelEncodingAlias (const char *alias)
 
: the encoding name, in UTF-8 format (ASCII actually)

xmlNewCharEncodingHandler:

@input: the xmlCharEncodingInputFunc to read that encoding @output: the xmlCharEncodingOutputFunc to write that encoding

Create and registers an xmlCharEncodingHandler.

Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error).

xmlCharEncodingHandlerPtr xmlNewCharEncodingHandler (const char *name, xmlCharEncodingInputFunc input, xmlCharEncodingOutputFunc output)
 
void xmlInitCharEncodingHandlers (void)
 
void xmlCleanupCharEncodingHandlers (void)
 
void xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler)
 
xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler (xmlCharEncoding enc)
 

Variables

static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL
 
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL
 
static xmlCharEncodingAliasPtr xmlCharEncodingAliases = NULL
 
static int xmlCharEncodingAliasesNb = 0
 
static int xmlCharEncodingAliasesMax = 0
 
static int xmlLittleEndian = 1
 

: the encoding name as parsed, in UTF-8 format (ASCII actually)

xmlParseCharEncoding:

Compare the string to the encoding schemes already known. Note that the comparison is case insensitive accordingly to the section [XML] 4.3.3 Character Encoding in Entities.

Returns one of the XML_CHAR_ENCODING_... values or XML_CHAR_ENCODING_NONE if not recognized.

#define MAX_ENCODING_HANDLERS   50
 
static xmlCharEncodingHandlerPtrhandlers = NULL
 
static int nbCharEncodingHandler = 0
 
static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL
 
xmlCharEncoding xmlParseCharEncoding (const char *name)
 
const charxmlGetCharEncodingName (xmlCharEncoding enc)
 

: a string describing the char encoding.

xmlFindCharEncodingHandler:

Search in the registered set the handler able to read/write that encoding.

Returns the handler or NULL if not found

#define bottom_encoding
 
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler (const char *name)
 
static int xmlEncInputChunk (xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush)
 
static int xmlEncOutputChunk (xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
 
int xmlCharEncFirstLineInt (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in, int len)
 
int xmlCharEncFirstLine (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in)
 
int xmlCharEncFirstLineInput (xmlParserInputBufferPtr input, int len)
 
int xmlCharEncInput (xmlParserInputBufferPtr input, int flush)
 
int xmlCharEncInFunc (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in)
 
int xmlCharEncOutFunc (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in)
 
int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler)
 
long xmlByteConsumed (xmlParserCtxtPtr ctxt)
 

Macro Definition Documentation

◆ bottom_encoding

#define bottom_encoding

Definition at line 3917 of file encoding.c.

◆ IN_LIBXML

#define IN_LIBXML

Definition at line 23 of file encoding.c.

◆ MAX_ENCODING_HANDLERS

#define MAX_ENCODING_HANDLERS   50

Definition at line 1296 of file encoding.c.

Typedef Documentation

◆ xmlCharEncodingAlias

Definition at line 54 of file encoding.c.

◆ xmlCharEncodingAliasPtr

Definition at line 55 of file encoding.c.

Function Documentation

◆ asciiToUTF8()

static int asciiToUTF8 ( unsigned char out,
int outlen,
const unsigned char in,
int inlen 
)
static

asciiToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @in: a pointer to an array of ASCII chars @inlen: the length of @in

Take a block of ASCII chars in and try to convert it to an UTF-8 block of chars out. Returns 0 if success, or -1 otherwise The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets consumed.

Definition at line 176 of file encoding.c.

177  {
178  unsigned char* outstart = out;
179  const unsigned char* base = in;
180  const unsigned char* processed = in;
181  unsigned char* outend = out + *outlen;
182  const unsigned char* inend;
183  unsigned int c;
184 
185  inend = in + (*inlen);
186  while ((in < inend) && (out - outstart + 5 < *outlen)) {
187  c= *in++;
188 
189  if (out >= outend)
190  break;
191  if (c < 0x80) {
192  *out++ = c;
193  } else {
194  *outlen = out - outstart;
195  *inlen = processed - base;
196  return(-1);
197  }
198 
199  processed = (const unsigned char*) in;
200  }
201  *outlen = out - outstart;
202  *inlen = processed - base;
203  return(*outlen);
204 }
GLuint base
Definition: 3dtext.c:35
const GLubyte * c
Definition: glext.h:8905
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616
static int processed(const type_t *type)
Definition: typegen.c:2236
#define c
Definition: ke_i.h:80

Referenced by xmlInitCharEncodingHandlers().

◆ isolat1ToUTF8()

int isolat1ToUTF8 ( unsigned char out,
int outlen,
const unsigned char in,
int inlen 
)

isolat1ToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @in: a pointer to an array of ISO Latin 1 chars @inlen: the length of @in

Take a block of ISO Latin 1 chars in and try to convert it to an UTF-8 block of chars out. Returns the number of bytes written if success, or -1 otherwise The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets consumed.

Definition at line 307 of file encoding.c.

308  {
309  unsigned char* outstart = out;
310  const unsigned char* base = in;
311  unsigned char* outend;
312  const unsigned char* inend;
313  const unsigned char* instop;
314 
315  if ((out == NULL) || (in == NULL) || (outlen == NULL) || (inlen == NULL))
316  return(-1);
317 
318  outend = out + *outlen;
319  inend = in + (*inlen);
320  instop = inend;
321 
322  while ((in < inend) && (out < outend - 1)) {
323  if (*in >= 0x80) {
324  *out++ = (((*in) >> 6) & 0x1F) | 0xC0;
325  *out++ = ((*in) & 0x3F) | 0x80;
326  ++in;
327  }
328  if ((instop - in) > (outend - out)) instop = in + (outend - out);
329  while ((in < instop) && (*in < 0x80)) {
330  *out++ = *in++;
331  }
332  }
333  if ((in < inend) && (out < outend) && (*in < 0x80)) {
334  *out++ = *in++;
335  }
336  *outlen = out - outstart;
337  *inlen = in - base;
338  return(*outlen);
339 }
GLuint base
Definition: 3dtext.c:35
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616

Referenced by xmlInitCharEncodingHandlers().

◆ LIBXML_ATTR_FORMAT()

static void LIBXML_ATTR_FORMAT ( ,
 
)
static

xmlErrEncoding: @error: the error number @msg: the error message

n encoding error

Definition at line 96 of file encoding.c.

98 {
99  __xmlRaiseError(NULL, NULL, NULL, NULL, NULL,
101  NULL, 0, val, NULL, NULL, 0, 0, msg, val);
102 }
#define error(str)
Definition: mkdosfs.c:1605
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
#define msg(x)
Definition: auth_time.c:54

◆ UTF16BEToUTF8()

static int UTF16BEToUTF8 ( unsigned char out,
int outlen,
const unsigned char inb,
int inlenb 
)
static

UTF16BEToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @inb: a pointer to an array of UTF-16 passed as a byte array @inlenb: the length of @in in UTF-16 chars

Take a block of UTF-16 ushorts in and try to convert it to an UTF-8 block of chars out. This function assumes the endian property is the same between the native type of this machine and the inputed one.

Returns the number of bytes written, or -1 if lack of space, or -2 if the transcoding fails (if *in is not a valid utf16 string) The value of *inlen after return is the number of octets consumed if the return value is positive, else unpredictable.

Definition at line 732 of file encoding.c.

734 {
735  unsigned char* outstart = out;
736  const unsigned char* processed = inb;
737  unsigned char* outend = out + *outlen;
738  unsigned short* in = (unsigned short*) inb;
739  unsigned short* inend;
740  unsigned int c, d, inlen;
741  unsigned char *tmp;
742  int bits;
743 
744  if ((*inlenb % 2) == 1)
745  (*inlenb)--;
746  inlen = *inlenb / 2;
747  inend= in + inlen;
748  while (in < inend) {
749  if (xmlLittleEndian) {
750  tmp = (unsigned char *) in;
751  c = *tmp++;
752  c = c << 8;
753  c = c | (unsigned int) *tmp;
754  in++;
755  } else {
756  c= *in++;
757  }
758  if ((c & 0xFC00) == 0xD800) { /* surrogates */
759  if (in >= inend) { /* (in > inend) shouldn't happens */
760  *outlen = out - outstart;
761  *inlenb = processed - inb;
762  return(-2);
763  }
764  if (xmlLittleEndian) {
765  tmp = (unsigned char *) in;
766  d = *tmp++;
767  d = d << 8;
768  d = d | (unsigned int) *tmp;
769  in++;
770  } else {
771  d= *in++;
772  }
773  if ((d & 0xFC00) == 0xDC00) {
774  c &= 0x03FF;
775  c <<= 10;
776  c |= d & 0x03FF;
777  c += 0x10000;
778  }
779  else {
780  *outlen = out - outstart;
781  *inlenb = processed - inb;
782  return(-2);
783  }
784  }
785 
786  /* assertion: c is a single UTF-4 value */
787  if (out >= outend)
788  break;
789  if (c < 0x80) { *out++= c; bits= -6; }
790  else if (c < 0x800) { *out++= ((c >> 6) & 0x1F) | 0xC0; bits= 0; }
791  else if (c < 0x10000) { *out++= ((c >> 12) & 0x0F) | 0xE0; bits= 6; }
792  else { *out++= ((c >> 18) & 0x07) | 0xF0; bits= 12; }
793 
794  for ( ; bits >= 0; bits-= 6) {
795  if (out >= outend)
796  break;
797  *out++= ((c >> bits) & 0x3F) | 0x80;
798  }
799  processed = (const unsigned char*) in;
800  }
801  *outlen = out - outstart;
802  *inlenb = processed - inb;
803  return(*outlen);
804 }
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define d
Definition: ke_i.h:81
static int xmlLittleEndian
Definition: encoding.c:75
const GLubyte * c
Definition: glext.h:8905
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616
static int processed(const type_t *type)
Definition: typegen.c:2236
#define c
Definition: ke_i.h:80
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by xmlInitCharEncodingHandlers().

◆ UTF16LEToUTF8()

static int UTF16LEToUTF8 ( unsigned char out,
int outlen,
const unsigned char inb,
int inlenb 
)
static

UTF16LEToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @inb: a pointer to an array of UTF-16LE passwd as a byte array @inlenb: the length of @in in UTF-16LE chars

Take a block of UTF-16LE ushorts in and try to convert it to an UTF-8 block of chars out. This function assumes the endian property is the same between the native type of this machine and the inputed one.

Returns the number of bytes written, or -1 if lack of space, or -2 if the transcoding fails (if *in is not a valid utf16 string) The value of *inlen after return is the number of octets consumed if the return value is positive, else unpredictable.

Definition at line 494 of file encoding.c.

496 {
497  unsigned char* outstart = out;
498  const unsigned char* processed = inb;
499  unsigned char* outend = out + *outlen;
500  unsigned short* in = (unsigned short*) inb;
501  unsigned short* inend;
502  unsigned int c, d, inlen;
503  unsigned char *tmp;
504  int bits;
505 
506  if ((*inlenb % 2) == 1)
507  (*inlenb)--;
508  inlen = *inlenb / 2;
509  inend = in + inlen;
510  while ((in < inend) && (out - outstart + 5 < *outlen)) {
511  if (xmlLittleEndian) {
512  c= *in++;
513  } else {
514  tmp = (unsigned char *) in;
515  c = *tmp++;
516  c = c | (((unsigned int)*tmp) << 8);
517  in++;
518  }
519  if ((c & 0xFC00) == 0xD800) { /* surrogates */
520  if (in >= inend) { /* (in > inend) shouldn't happens */
521  break;
522  }
523  if (xmlLittleEndian) {
524  d = *in++;
525  } else {
526  tmp = (unsigned char *) in;
527  d = *tmp++;
528  d = d | (((unsigned int)*tmp) << 8);
529  in++;
530  }
531  if ((d & 0xFC00) == 0xDC00) {
532  c &= 0x03FF;
533  c <<= 10;
534  c |= d & 0x03FF;
535  c += 0x10000;
536  }
537  else {
538  *outlen = out - outstart;
539  *inlenb = processed - inb;
540  return(-2);
541  }
542  }
543 
544  /* assertion: c is a single UTF-4 value */
545  if (out >= outend)
546  break;
547  if (c < 0x80) { *out++= c; bits= -6; }
548  else if (c < 0x800) { *out++= ((c >> 6) & 0x1F) | 0xC0; bits= 0; }
549  else if (c < 0x10000) { *out++= ((c >> 12) & 0x0F) | 0xE0; bits= 6; }
550  else { *out++= ((c >> 18) & 0x07) | 0xF0; bits= 12; }
551 
552  for ( ; bits >= 0; bits-= 6) {
553  if (out >= outend)
554  break;
555  *out++= ((c >> bits) & 0x3F) | 0x80;
556  }
557  processed = (const unsigned char*) in;
558  }
559  *outlen = out - outstart;
560  *inlenb = processed - inb;
561  return(*outlen);
562 }
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define d
Definition: ke_i.h:81
static int xmlLittleEndian
Definition: encoding.c:75
const GLubyte * c
Definition: glext.h:8905
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616
static int processed(const type_t *type)
Definition: typegen.c:2236
#define c
Definition: ke_i.h:80
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by xmlInitCharEncodingHandlers().

◆ UTF8ToUTF8()

static int UTF8ToUTF8 ( unsigned char out,
int outlen,
const unsigned char inb,
int inlenb 
)
static

UTF8ToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @inb: a pointer to an array of UTF-8 chars @inlenb: the length of @in in UTF-8 chars

No op copy operation for UTF8 handling.

Returns the number of bytes written, or -1 if lack of space. The value of *inlen after return is the number of octets consumed if the return value is positive, else unpredictable.

Definition at line 355 of file encoding.c.

357 {
358  int len;
359 
360  if ((out == NULL) || (outlen == NULL) || (inlenb == NULL))
361  return(-1);
362  if (inb == NULL) {
363  /* inb == NULL means output is initialized. */
364  *outlen = 0;
365  *inlenb = 0;
366  return(0);
367  }
368  if (*outlen > *inlenb) {
369  len = *inlenb;
370  } else {
371  len = *outlen;
372  }
373  if (len < 0)
374  return(-1);
375 
376  memcpy(out, inb, len);
377 
378  *outlen = len;
379  *inlenb = len;
380  return(*outlen);
381 }
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722

Referenced by xmlInitCharEncodingHandlers().

◆ xmlAddEncodingAlias()

int xmlAddEncodingAlias ( const char name,
const char alias 
)

Definition at line 1057 of file encoding.c.

1057  {
1058  int i;
1059  char upper[100];
1060 
1061  if ((name == NULL) || (alias == NULL))
1062  return(-1);
1063 
1064  for (i = 0;i < 99;i++) {
1065  upper[i] = toupper(alias[i]);
1066  if (upper[i] == 0) break;
1067  }
1068  upper[i] = 0;
1069 
1070  if (xmlCharEncodingAliases == NULL) {
1076  return(-1);
1082  }
1083  /*
1084  * Walk down the list looking for a definition of the alias
1085  */
1086  for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
1087  if (!strcmp(xmlCharEncodingAliases[i].alias, upper)) {
1088  /*
1089  * Replace the definition.
1090  */
1091  xmlFree((char *) xmlCharEncodingAliases[i].name);
1093  return(0);
1094  }
1095  }
1096  /*
1097  * Add the definition
1098  */
1102  return(0);
1103 }
const char * name
Definition: encoding.c:57
static xmlCharEncodingAliasPtr xmlCharEncodingAliases
Definition: encoding.c:61
static int xmlCharEncodingAliasesMax
Definition: encoding.c:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
int toupper(int c)
Definition: utclib.c:881
const char * alias
Definition: encoding.c:58
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int xmlCharEncodingAliasesNb
Definition: encoding.c:62
xmlCharEncodingAlias * xmlCharEncodingAliasPtr
Definition: encoding.c:55
const WCHAR * alias
Definition: main.c:67
XMLPUBVAR xmlStrdupFunc xmlMemStrdup
Definition: globals.h:251
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by main().

◆ xmlByteConsumed()

long xmlByteConsumed ( xmlParserCtxtPtr  ctxt)

xmlByteConsumed: @ctxt: an XML parser context

This function provides the current index of the parser relative to the start of the current entity. This function is computed in bytes from the beginning starting at zero and finishing at the size in byte of the file if parsing a file. The function is of constant cost if the input is UTF-8 but can be costly if run on non-UTF-8 input.

Returns the index in bytes from the beginning of the entity or -1 in case the index could not be computed.

Definition at line 2803 of file encoding.c.

2803  {
2805 
2806  if (ctxt == NULL) return(-1);
2807  in = ctxt->input;
2808  if (in == NULL) return(-1);
2809  if ((in->buf != NULL) && (in->buf->encoder != NULL)) {
2810  unsigned int unused = 0;
2811  xmlCharEncodingHandler * handler = in->buf->encoder;
2812  /*
2813  * Encoding conversion, compute the number of unused original
2814  * bytes from the input not consumed and substract that from
2815  * the raw consumed value, this is not a cheap operation
2816  */
2817  if (in->end - in->cur > 0) {
2818  unsigned char convbuf[32000];
2819  const unsigned char *cur = (const unsigned char *)in->cur;
2820  int toconv = in->end - in->cur, written = 32000;
2821 
2822  int ret;
2823 
2824  do {
2825  toconv = in->end - cur;
2826  written = 32000;
2827  ret = xmlEncOutputChunk(handler, &convbuf[0], &written,
2828  cur, &toconv);
2829  if (ret < 0) {
2830  if (written > 0)
2831  ret = -2;
2832  else
2833  return(-1);
2834  }
2835  unused += written;
2836  cur += toconv;
2837  } while (ret == -2);
2838  }
2839  if (in->buf->rawconsumed < unused)
2840  return(-1);
2841  return(in->buf->rawconsumed - unused);
2842  }
2843  return(in->consumed + (in->cur - in->base));
2844 }
xmlParserInputPtr input
Definition: parser.h:199
static int xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
Definition: encoding.c:1946
WORD unused[29]
Definition: crypt.c:1155
smooth NULL
Definition: ftsmooth.c:416
int ret
GLuint in
Definition: glext.h:9616
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

◆ xmlCharEncCloseFunc()

int xmlCharEncCloseFunc ( xmlCharEncodingHandler handler)

xmlCharEncCloseFunc: @handler: char enconding transformation data structure

Generic front-end for encoding handler close function

Returns 0 if success, or -1 in case of error

Definition at line 2720 of file encoding.c.

2720  {
2721  int ret = 0;
2722  int tofree = 0;
2723  int i, handler_in_list = 0;
2724 
2725  if (handler == NULL) return(-1);
2726  if (handler->name == NULL) return(-1);
2727  if (handlers != NULL) {
2728  for (i = 0;i < nbCharEncodingHandler; i++) {
2729  if (handler == handlers[i]) {
2730  handler_in_list = 1;
2731  break;
2732  }
2733  }
2734  }
2735 #ifdef LIBXML_ICONV_ENABLED
2736  /*
2737  * Iconv handlers can be used only once, free the whole block.
2738  * and the associated icon resources.
2739  */
2740  if ((handler_in_list == 0) &&
2741  ((handler->iconv_out != NULL) || (handler->iconv_in != NULL))) {
2742  tofree = 1;
2743  if (handler->iconv_out != NULL) {
2744  if (iconv_close(handler->iconv_out))
2745  ret = -1;
2746  handler->iconv_out = NULL;
2747  }
2748  if (handler->iconv_in != NULL) {
2749  if (iconv_close(handler->iconv_in))
2750  ret = -1;
2751  handler->iconv_in = NULL;
2752  }
2753  }
2754 #endif /* LIBXML_ICONV_ENABLED */
2755 #ifdef LIBXML_ICU_ENABLED
2756  if ((handler_in_list == 0) &&
2757  ((handler->uconv_out != NULL) || (handler->uconv_in != NULL))) {
2758  tofree = 1;
2759  if (handler->uconv_out != NULL) {
2760  closeIcuConverter(handler->uconv_out);
2761  handler->uconv_out = NULL;
2762  }
2763  if (handler->uconv_in != NULL) {
2764  closeIcuConverter(handler->uconv_in);
2765  handler->uconv_in = NULL;
2766  }
2767  }
2768 #endif
2769  if (tofree) {
2770  /* free up only dynamic handlers iconv/uconv */
2771  if (handler->name != NULL)
2772  xmlFree(handler->name);
2773  handler->name = NULL;
2774  xmlFree(handler);
2775  }
2776 #ifdef DEBUG_ENCODING
2777  if (ret)
2779  "failed to close the encoding handler\n");
2780  else
2782  "closed the encoding handler\n");
2783 #endif
2784 
2785  return(ret);
2786 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1297
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
int ret
static int nbCharEncodingHandler
Definition: encoding.c:1298
int iconv_close(iconv_t cd)
Definition: win_iconv.c:756
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlSwitchInputEncodingInt().

◆ xmlCharEncFirstLine()

int xmlCharEncFirstLine ( xmlCharEncodingHandler handler,
xmlBufferPtr  out,
xmlBufferPtr  in 
)

xmlCharEncFirstLine: @handler: char enconding transformation data structure @out: an xmlBuffer for the output. @in: an xmlBuffer for the input

Front-end for the encoding handler input function, but handle only the very first line, i.e. limit itself to 45 chars.

Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or

Definition at line 2075 of file encoding.c.

2076  {
2077  return(xmlCharEncFirstLineInt(handler, out, in, -1));
2078 }
int xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in, int len)
Definition: encoding.c:1989
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

◆ xmlCharEncFirstLineInput()

int xmlCharEncFirstLineInput ( xmlParserInputBufferPtr  input,
int  len 
)

xmlCharEncFirstLineInput: @input: a parser input buffer @len: number of bytes to convert for the first line, or -1

Front-end for the encoding handler input function, but handle only the very first line. Point is that this is based on autodetection of the encoding and once that first line is converted we may find out that a different decoder is needed to process the input.

Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or

Definition at line 2096 of file encoding.c.

2097 {
2098  int ret;
2099  size_t written;
2100  size_t toconv;
2101  int c_in;
2102  int c_out;
2103  xmlBufPtr in;
2104  xmlBufPtr out;
2105 
2106  if ((input == NULL) || (input->encoder == NULL) ||
2107  (input->buffer == NULL) || (input->raw == NULL))
2108  return (-1);
2109  out = input->buffer;
2110  in = input->raw;
2111 
2112  toconv = xmlBufUse(in);
2113  if (toconv == 0)
2114  return (0);
2115  written = xmlBufAvail(out) - 1; /* count '\0' */
2116  /*
2117  * echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
2118  * 45 chars should be sufficient to reach the end of the encoding
2119  * declaration without going too far inside the document content.
2120  * on UTF-16 this means 90bytes, on UCS4 this means 180
2121  * The actual value depending on guessed encoding is passed as @len
2122  * if provided
2123  */
2124  if (len >= 0) {
2125  if (toconv > (unsigned int) len)
2126  toconv = len;
2127  } else {
2128  if (toconv > 180)
2129  toconv = 180;
2130  }
2131  if (toconv * 2 >= written) {
2132  xmlBufGrow(out, toconv * 2);
2133  written = xmlBufAvail(out) - 1;
2134  }
2135  if (written > 360)
2136  written = 360;
2137 
2138  c_in = toconv;
2139  c_out = written;
2140  ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
2141  xmlBufContent(in), &c_in, 0);
2142  xmlBufShrink(in, c_in);
2143  xmlBufAddLen(out, c_out);
2144  if (ret == -1)
2145  ret = -3;
2146 
2147  switch (ret) {
2148  case 0:
2149 #ifdef DEBUG_ENCODING
2151  "converted %d bytes to %d bytes of input\n",
2152  c_in, c_out);
2153 #endif
2154  break;
2155  case -1:
2156 #ifdef DEBUG_ENCODING
2158  "converted %d bytes to %d bytes of input, %d left\n",
2159  c_in, c_out, (int)xmlBufUse(in));
2160 #endif
2161  break;
2162  case -3:
2163 #ifdef DEBUG_ENCODING
2165  "converted %d bytes to %d bytes of input, %d left\n",
2166  c_in, c_out, (int)xmlBufUse(in));
2167 #endif
2168  break;
2169  case -2: {
2170  char buf[50];
2171  const xmlChar *content = xmlBufContent(in);
2172 
2173  snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
2174  content[0], content[1],
2175  content[2], content[3]);
2176  buf[49] = 0;
2177  xmlEncodingErr(XML_I18N_CONV_FAILED,
2178  "input conversion failed due to input error, bytes %s\n",
2179  buf);
2180  }
2181  }
2182  /*
2183  * Ignore when input buffer is not on a boundary
2184  */
2185  if (ret == -3) ret = 0;
2186  if (ret == -1) ret = 0;
2187  return(ret);
2188 }
int xmlBufGrow(xmlBufPtr buf, int len)
Definition: buf.c:509
XMLPUBFUN xmlChar *XMLCALL xmlBufContent(const xmlBuf *buf)
Definition: buf.c:582
int xmlBufAddLen(xmlBufPtr buf, size_t len)
Definition: buf.c:621
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN xmlChar *XMLCALL xmlBufEnd(xmlBufPtr buf)
Definition: buf.c:600
#define snprintf
Definition: wintirpc.h:48
static int xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush)
Definition: encoding.c:1916
Definition: buf.c:43
content
Definition: atl_ax.c:994
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
size_t xmlBufAvail(const xmlBufPtr buf)
Definition: buf.c:708
GLenum GLenum GLenum input
Definition: glext.h:9031
GLuint in
Definition: glext.h:9616
XMLPUBFUN size_t XMLCALL xmlBufUse(const xmlBufPtr buf)
Definition: buf.c:687
XMLPUBFUN size_t XMLCALL xmlBufShrink(xmlBufPtr buf, size_t len)
Definition: buf.c:388
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlSwitchInputEncodingInt().

◆ xmlCharEncFirstLineInt()

int xmlCharEncFirstLineInt ( xmlCharEncodingHandler handler,
xmlBufferPtr  out,
xmlBufferPtr  in,
int  len 
)

xmlCharEncFirstLineInt: @handler: char enconding transformation data structure @out: an xmlBuffer for the output. @in: an xmlBuffer for the input @len: number of bytes to convert for the first line, or -1

Front-end for the encoding handler input function, but handle only the very first line, i.e. limit itself to 45 chars.

Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or

Definition at line 1989 of file encoding.c.

1990  {
1991  int ret;
1992  int written;
1993  int toconv;
1994 
1995  if (handler == NULL) return(-1);
1996  if (out == NULL) return(-1);
1997  if (in == NULL) return(-1);
1998 
1999  /* calculate space available */
2000  written = out->size - out->use - 1; /* count '\0' */
2001  toconv = in->use;
2002  /*
2003  * echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
2004  * 45 chars should be sufficient to reach the end of the encoding
2005  * declaration without going too far inside the document content.
2006  * on UTF-16 this means 90bytes, on UCS4 this means 180
2007  * The actual value depending on guessed encoding is passed as @len
2008  * if provided
2009  */
2010  if (len >= 0) {
2011  if (toconv > len)
2012  toconv = len;
2013  } else {
2014  if (toconv > 180)
2015  toconv = 180;
2016  }
2017  if (toconv * 2 >= written) {
2018  xmlBufferGrow(out, toconv * 2);
2019  written = out->size - out->use - 1;
2020  }
2021 
2022  ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
2023  in->content, &toconv, 0);
2024  xmlBufferShrink(in, toconv);
2025  out->use += written;
2026  out->content[out->use] = 0;
2027  if (ret == -1) ret = -3;
2028 
2029 #ifdef DEBUG_ENCODING
2030  switch (ret) {
2031  case 0:
2033  "converted %d bytes to %d bytes of input\n",
2034  toconv, written);
2035  break;
2036  case -1:
2037  xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
2038  toconv, written, in->use);
2039  break;
2040  case -2:
2042  "input conversion failed due to input error\n");
2043  break;
2044  case -3:
2045  xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
2046  toconv, written, in->use);
2047  break;
2048  default:
2049  xmlGenericError(xmlGenericErrorContext,"Unknown input conversion failed %d\n", ret);
2050  }
2051 #endif /* DEBUG_ENCODING */
2052  /*
2053  * Ignore when input buffer is not on a boundary
2054  */
2055  if (ret == -3) ret = 0;
2056  if (ret == -1) ret = 0;
2057  return(ret);
2058 }
static int xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush)
Definition: encoding.c:1916
XMLPUBFUN int XMLCALL xmlBufferGrow(xmlBufferPtr buf, unsigned int len)
XMLPUBFUN int XMLCALL xmlBufferShrink(xmlBufferPtr buf, unsigned int len)
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int ret
GLenum GLsizei len
Definition: glext.h:6722
GLuint in
Definition: glext.h:9616
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlCharEncFirstLine().

◆ xmlCharEncInFunc()

int xmlCharEncInFunc ( xmlCharEncodingHandler handler,
xmlBufferPtr  out,
xmlBufferPtr  in 
)

xmlCharEncInFunc: @handler: char encoding transformation data structure @out: an xmlBuffer for the output. @in: an xmlBuffer for the input

Generic front-end for the encoding handler input function

Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or

Definition at line 2302 of file encoding.c.

2304 {
2305  int ret;
2306  int written;
2307  int toconv;
2308 
2309  if (handler == NULL)
2310  return (-1);
2311  if (out == NULL)
2312  return (-1);
2313  if (in == NULL)
2314  return (-1);
2315 
2316  toconv = in->use;
2317  if (toconv == 0)
2318  return (0);
2319  written = out->size - out->use -1; /* count '\0' */
2320  if (toconv * 2 >= written) {
2321  xmlBufferGrow(out, out->size + toconv * 2);
2322  written = out->size - out->use - 1;
2323  }
2324  ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
2325  in->content, &toconv, 1);
2326  xmlBufferShrink(in, toconv);
2327  out->use += written;
2328  out->content[out->use] = 0;
2329  if (ret == -1)
2330  ret = -3;
2331 
2332  switch (ret) {
2333  case 0:
2334 #ifdef DEBUG_ENCODING
2336  "converted %d bytes to %d bytes of input\n",
2337  toconv, written);
2338 #endif
2339  break;
2340  case -1:
2341 #ifdef DEBUG_ENCODING
2343  "converted %d bytes to %d bytes of input, %d left\n",
2344  toconv, written, in->use);
2345 #endif
2346  break;
2347  case -3:
2348 #ifdef DEBUG_ENCODING
2350  "converted %d bytes to %d bytes of input, %d left\n",
2351  toconv, written, in->use);
2352 #endif
2353  break;
2354  case -2: {
2355  char buf[50];
2356 
2357  snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
2358  in->content[0], in->content[1],
2359  in->content[2], in->content[3]);
2360  buf[49] = 0;
2361  xmlEncodingErr(XML_I18N_CONV_FAILED,
2362  "input conversion failed due to input error, bytes %s\n",
2363  buf);
2364  }
2365  }
2366  /*
2367  * Ignore when input buffer is not on a boundary
2368  */
2369  if (ret == -3)
2370  ret = 0;
2371  return (written? written : ret);
2372 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define snprintf
Definition: wintirpc.h:48
static int xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush)
Definition: encoding.c:1916
XMLPUBFUN int XMLCALL xmlBufferGrow(xmlBufferPtr buf, unsigned int len)
XMLPUBFUN int XMLCALL xmlBufferShrink(xmlBufferPtr buf, unsigned int len)
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int ret
GLuint in
Definition: glext.h:9616
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ xmlCharEncInput()

int xmlCharEncInput ( xmlParserInputBufferPtr  input,
int  flush 
)

xmlCharEncInput: @input: a parser input buffer @flush: try to flush all the raw buffer

Generic front-end for the encoding handler on parser input

Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or

Definition at line 2203 of file encoding.c.

2204 {
2205  int ret;
2206  size_t written;
2207  size_t toconv;
2208  int c_in;
2209  int c_out;
2210  xmlBufPtr in;
2211  xmlBufPtr out;
2212 
2213  if ((input == NULL) || (input->encoder == NULL) ||
2214  (input->buffer == NULL) || (input->raw == NULL))
2215  return (-1);
2216  out = input->buffer;
2217  in = input->raw;
2218 
2219  toconv = xmlBufUse(in);
2220  if (toconv == 0)
2221  return (0);
2222  if ((toconv > 64 * 1024) && (flush == 0))
2223  toconv = 64 * 1024;
2224  written = xmlBufAvail(out);
2225  if (written > 0)
2226  written--; /* count '\0' */
2227  if (toconv * 2 >= written) {
2228  xmlBufGrow(out, toconv * 2);
2229  written = xmlBufAvail(out);
2230  if (written > 0)
2231  written--; /* count '\0' */
2232  }
2233  if ((written > 128 * 1024) && (flush == 0))
2234  written = 128 * 1024;
2235 
2236  c_in = toconv;
2237  c_out = written;
2238  ret = xmlEncInputChunk(input->encoder, xmlBufEnd(out), &c_out,
2239  xmlBufContent(in), &c_in, flush);
2240  xmlBufShrink(in, c_in);
2241  xmlBufAddLen(out, c_out);
2242  if (ret == -1)
2243  ret = -3;
2244 
2245  switch (ret) {
2246  case 0:
2247 #ifdef DEBUG_ENCODING
2249  "converted %d bytes to %d bytes of input\n",
2250  c_in, c_out);
2251 #endif
2252  break;
2253  case -1:
2254 #ifdef DEBUG_ENCODING
2256  "converted %d bytes to %d bytes of input, %d left\n",
2257  c_in, c_out, (int)xmlBufUse(in));
2258 #endif
2259  break;
2260  case -3:
2261 #ifdef DEBUG_ENCODING
2263  "converted %d bytes to %d bytes of input, %d left\n",
2264  c_in, c_out, (int)xmlBufUse(in));
2265 #endif
2266  break;
2267  case -2: {
2268  char buf[50];
2269  const xmlChar *content = xmlBufContent(in);
2270 
2271  snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
2272  content[0], content[1],
2273  content[2], content[3]);
2274  buf[49] = 0;
2275  xmlEncodingErr(XML_I18N_CONV_FAILED,
2276  "input conversion failed due to input error, bytes %s\n",
2277  buf);
2278  }
2279  }
2280  /*
2281  * Ignore when input buffer is not on a boundary
2282  */
2283  if (ret == -3)
2284  ret = 0;
2285  return (c_out? c_out : ret);
2286 }
int xmlBufGrow(xmlBufPtr buf, int len)
Definition: buf.c:509
XMLPUBFUN xmlChar *XMLCALL xmlBufContent(const xmlBuf *buf)
Definition: buf.c:582
int xmlBufAddLen(xmlBufPtr buf, size_t len)
Definition: buf.c:621
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN xmlChar *XMLCALL xmlBufEnd(xmlBufPtr buf)
Definition: buf.c:600
#define snprintf
Definition: wintirpc.h:48
static int xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int flush)
Definition: encoding.c:1916
Definition: buf.c:43
content
Definition: atl_ax.c:994
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int flush
Definition: zlib.h:309
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
size_t xmlBufAvail(const xmlBufPtr buf)
Definition: buf.c:708
GLenum GLenum GLenum input
Definition: glext.h:9031
GLuint in
Definition: glext.h:9616
XMLPUBFUN size_t XMLCALL xmlBufUse(const xmlBufPtr buf)
Definition: buf.c:687
XMLPUBFUN size_t XMLCALL xmlBufShrink(xmlBufPtr buf, size_t len)
Definition: buf.c:388
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlSwitchInputEncodingInt().

◆ xmlCharEncOutFunc()

int xmlCharEncOutFunc ( xmlCharEncodingHandler handler,
xmlBufferPtr  out,
xmlBufferPtr  in 
)

xmlCharEncOutFunc: @handler: char enconding transformation data structure @out: an xmlBuffer for the output. @in: an xmlBuffer for the input

Generic front-end for the encoding handler output function a first call with @in == NULL has to be made firs to initiate the output in case of non-stateless encoding needing to initiate their state or the output (like the BOM in UTF16). In case of UTF8 sequence conversion errors for the given encoder, the content will be automatically remapped to a CharRef sequence.

Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or

Definition at line 2566 of file encoding.c.

2567  {
2568  int ret;
2569  int written;
2570  int writtentot = 0;
2571  int toconv;
2572  int output = 0;
2573 
2574  if (handler == NULL) return(-1);
2575  if (out == NULL) return(-1);
2576 
2577 retry:
2578 
2579  written = out->size - out->use;
2580 
2581  if (written > 0)
2582  written--; /* Gennady: count '/0' */
2583 
2584  /*
2585  * First specific handling of in = NULL, i.e. the initialization call
2586  */
2587  if (in == NULL) {
2588  toconv = 0;
2589  /* TODO: Check return value. */
2590  xmlEncOutputChunk(handler, &out->content[out->use], &written,
2591  NULL, &toconv);
2592  out->use += written;
2593  out->content[out->use] = 0;
2594 #ifdef DEBUG_ENCODING
2596  "initialized encoder\n");
2597 #endif
2598  return(0);
2599  }
2600 
2601  /*
2602  * Conversion itself.
2603  */
2604  toconv = in->use;
2605  if (toconv == 0)
2606  return(0);
2607  if (toconv * 4 >= written) {
2608  xmlBufferGrow(out, toconv * 4);
2609  written = out->size - out->use - 1;
2610  }
2611  ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
2612  in->content, &toconv);
2613  xmlBufferShrink(in, toconv);
2614  out->use += written;
2615  writtentot += written;
2616  out->content[out->use] = 0;
2617  if (ret == -1) {
2618  if (written > 0) {
2619  /* Can be a limitation of iconv or uconv */
2620  goto retry;
2621  }
2622  ret = -3;
2623  }
2624 
2625  if (ret >= 0) output += ret;
2626 
2627  /*
2628  * Attempt to handle error cases
2629  */
2630  switch (ret) {
2631  case 0:
2632 #ifdef DEBUG_ENCODING
2634  "converted %d bytes to %d bytes of output\n",
2635  toconv, written);
2636 #endif
2637  break;
2638  case -1:
2639 #ifdef DEBUG_ENCODING
2641  "output conversion failed by lack of space\n");
2642 #endif
2643  break;
2644  case -3:
2645 #ifdef DEBUG_ENCODING
2646  xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
2647  toconv, written, in->use);
2648 #endif
2649  break;
2650  case -4:
2651  xmlEncodingErr(XML_I18N_NO_OUTPUT,
2652  "xmlCharEncOutFunc: no output function !\n", NULL);
2653  ret = -1;
2654  break;
2655  case -2: {
2656  xmlChar charref[20];
2657  int len = in->use;
2658  const xmlChar *utf = (const xmlChar *) in->content;
2659  int cur, charrefLen;
2660 
2661  cur = xmlGetUTF8Char(utf, &len);
2662  if (cur <= 0)
2663  break;
2664 
2665 #ifdef DEBUG_ENCODING
2667  "handling output conversion error\n");
2669  "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
2670  in->content[0], in->content[1],
2671  in->content[2], in->content[3]);
2672 #endif
2673  /*
2674  * Removes the UTF8 sequence, and replace it by a charref
2675  * and continue the transcoding phase, hoping the error
2676  * did not mangle the encoder state.
2677  */
2678  charrefLen = snprintf((char *) &charref[0], sizeof(charref),
2679  "&#%d;", cur);
2681  xmlBufferGrow(out, charrefLen * 4);
2682  written = out->size - out->use - 1;
2683  toconv = charrefLen;
2684  ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
2685  charref, &toconv);
2686 
2687  if ((ret < 0) || (toconv != charrefLen)) {
2688  char buf[50];
2689 
2690  snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
2691  in->content[0], in->content[1],
2692  in->content[2], in->content[3]);
2693  buf[49] = 0;
2694  xmlEncodingErr(XML_I18N_CONV_FAILED,
2695  "output conversion failed due to conv error, bytes %s\n",
2696  buf);
2697  if (in->alloc != XML_BUFFER_ALLOC_IMMUTABLE)
2698  in->content[0] = ' ';
2699  break;
2700  }
2701 
2702  out->use += written;
2703  writtentot += written;
2704  out->content[out->use] = 0;
2705  goto retry;
2706  }
2707  }
2708  return(ret);
2709 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define snprintf
Definition: wintirpc.h:48
XMLPUBFUN int XMLCALL xmlBufferGrow(xmlBufferPtr buf, unsigned int len)
static int xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
Definition: encoding.c:1946
XMLPUBFUN int XMLCALL xmlBufferShrink(xmlBufferPtr buf, unsigned int len)
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
GLuint in
Definition: glext.h:9616
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL xmlGetUTF8Char(const unsigned char *utf, int *len)
Definition: xmlstring.c:710
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ xmlCleanupCharEncodingHandlers()

void xmlCleanupCharEncodingHandlers ( void  )

xmlCleanupCharEncodingHandlers:

Cleanup the memory allocated for the char encoding support, it unregisters all the encoding handlers and the aliases.

Definition at line 1455 of file encoding.c.

1455  {
1457 
1458  if (handlers == NULL) return;
1459 
1460  for (;nbCharEncodingHandler > 0;) {
1466  }
1467  }
1468  xmlFree(handlers);
1469  handlers = NULL;
1472 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1297
static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler
Definition: encoding.c:1305
smooth NULL
Definition: ftsmooth.c:416
void xmlCleanupEncodingAliases(void)
Definition: encoding.c:992
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int nbCharEncodingHandler
Definition: encoding.c:1298
Definition: name.c:36

Referenced by xmlCleanupParser().

◆ xmlCleanupEncodingAliases()

void xmlCleanupEncodingAliases ( void  )

xmlCleanupEncodingAliases:

Unregisters all aliases

Definition at line 992 of file encoding.c.

992  {
993  int i;
994 
996  return;
997 
998  for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
1000  xmlFree((char *) xmlCharEncodingAliases[i].name);
1003  }
1008 }
static xmlCharEncodingAliasPtr xmlCharEncodingAliases
Definition: encoding.c:61
static int xmlCharEncodingAliasesMax
Definition: encoding.c:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int xmlCharEncodingAliasesNb
Definition: encoding.c:62
const WCHAR * alias
Definition: main.c:67
Definition: name.c:36

Referenced by xmlCleanupCharEncodingHandlers().

◆ xmlDelEncodingAlias()

int xmlDelEncodingAlias ( const char alias)

xmlDelEncodingAlias: @alias: the alias name as parsed, in UTF-8 format (ASCII actually)

Unregisters an encoding alias @alias

Returns 0 in case of success, -1 in case of error

Definition at line 1114 of file encoding.c.

1114  {
1115  int i;
1116 
1117  if (alias == NULL)
1118  return(-1);
1119 
1121  return(-1);
1122  /*
1123  * Walk down the list looking for a definition of the alias
1124  */
1125  for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
1127  xmlFree((char *) xmlCharEncodingAliases[i].name);
1132  return(0);
1133  }
1134  }
1135  return(-1);
1136 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static xmlCharEncodingAliasPtr xmlCharEncodingAliases
Definition: encoding.c:61
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int xmlCharEncodingAliasesNb
Definition: encoding.c:62
const WCHAR * alias
Definition: main.c:67
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

◆ xmlDetectCharEncoding()

xmlCharEncoding xmlDetectCharEncoding ( const unsigned char in,
int  len 
)

xmlDetectCharEncoding: @in: a pointer to the first bytes of the XML entity, must be at least 2 bytes long (at least 4 if encoding is UTF4 variant). @len: pointer to the length of the buffer

Guess the encoding of the entity using the first bytes of the entity content according to the non-normative appendix F of the XML-1.0 recommendation.

Returns one of the XML_CHAR_ENCODING_... values.

Definition at line 932 of file encoding.c.

933 {
934  if (in == NULL)
935  return(XML_CHAR_ENCODING_NONE);
936  if (len >= 4) {
937  if ((in[0] == 0x00) && (in[1] == 0x00) &&
938  (in[2] == 0x00) && (in[3] == 0x3C))
939  return(XML_CHAR_ENCODING_UCS4BE);
940  if ((in[0] == 0x3C) && (in[1] == 0x00) &&
941  (in[2] == 0x00) && (in[3] == 0x00))
942  return(XML_CHAR_ENCODING_UCS4LE);
943  if ((in[0] == 0x00) && (in[1] == 0x00) &&
944  (in[2] == 0x3C) && (in[3] == 0x00))
946  if ((in[0] == 0x00) && (in[1] == 0x3C) &&
947  (in[2] == 0x00) && (in[3] == 0x00))
949  if ((in[0] == 0x4C) && (in[1] == 0x6F) &&
950  (in[2] == 0xA7) && (in[3] == 0x94))
951  return(XML_CHAR_ENCODING_EBCDIC);
952  if ((in[0] == 0x3C) && (in[1] == 0x3F) &&
953  (in[2] == 0x78) && (in[3] == 0x6D))
954  return(XML_CHAR_ENCODING_UTF8);
955  /*
956  * Although not part of the recommendation, we also
957  * attempt an "auto-recognition" of UTF-16LE and
958  * UTF-16BE encodings.
959  */
960  if ((in[0] == 0x3C) && (in[1] == 0x00) &&
961  (in[2] == 0x3F) && (in[3] == 0x00))
963  if ((in[0] == 0x00) && (in[1] == 0x3C) &&
964  (in[2] == 0x00) && (in[3] == 0x3F))
966  }
967  if (len >= 3) {
968  /*
969  * Errata on XML-1.0 June 20 2001
970  * We now allow an UTF8 encoded BOM
971  */
972  if ((in[0] == 0xEF) && (in[1] == 0xBB) &&
973  (in[2] == 0xBF))
974  return(XML_CHAR_ENCODING_UTF8);
975  }
976  /* For UTF-16 we can recognize by the BOM */
977  if (len >= 2) {
978  if ((in[0] == 0xFE) && (in[1] == 0xFF))
980  if ((in[0] == 0xFF) && (in[1] == 0xFE))
982  }
983  return(XML_CHAR_ENCODING_NONE);
984 }
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722
GLuint in
Definition: glext.h:9616

Referenced by xmlCtxtResetPush(), xmlParseCtxtExternalEntity(), xmlParseDocument(), xmlParseExternalEntityPrivate(), xmlParseExternalSubset(), xmlParseExtParsedEnt(), xmlParsePEReference(), and xmlSAX2ExternalSubset().

◆ xmlEncInputChunk()

static int xmlEncInputChunk ( xmlCharEncodingHandler handler,
unsigned char out,
int outlen,
const unsigned char in,
int inlen,
int  flush 
)
static

Definition at line 1916 of file encoding.c.

1917  {
1918  int ret;
1919  (void)flush;
1920 
1921  if (handler->input != NULL) {
1922  ret = handler->input(out, outlen, in, inlen);
1923  }
1924 #ifdef LIBXML_ICONV_ENABLED
1925  else if (handler->iconv_in != NULL) {
1926  ret = xmlIconvWrapper(handler->iconv_in, out, outlen, in, inlen);
1927  }
1928 #endif /* LIBXML_ICONV_ENABLED */
1929 #ifdef LIBXML_ICU_ENABLED
1930  else if (handler->uconv_in != NULL) {
1931  ret = xmlUconvWrapper(handler->uconv_in, 1, out, outlen, in, inlen,
1932  flush);
1933  }
1934 #endif /* LIBXML_ICU_ENABLED */
1935  else {
1936  *outlen = 0;
1937  *inlen = 0;
1938  ret = -2;
1939  }
1940 
1941  return(ret);
1942 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int flush
Definition: zlib.h:309
int ret
GLuint in
Definition: glext.h:9616
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

Referenced by xmlCharEncFirstLineInput(), xmlCharEncFirstLineInt(), xmlCharEncInFunc(), and xmlCharEncInput().

◆ xmlEncodingErrMemory()

static void xmlEncodingErrMemory ( const char extra)
static

xmlEncodingErrMemory: @extra: extra informations

Handle an out of memory condition

Definition at line 84 of file encoding.c.

85 {
86  __xmlSimpleError(XML_FROM_I18N, XML_ERR_NO_MEMORY, NULL, NULL, extra);
87 }
smooth NULL
Definition: ftsmooth.c:416
Definition: id3.c:18

Referenced by xmlInitCharEncodingHandlers(), and xmlNewCharEncodingHandler().

◆ xmlEncOutputChunk()

static int xmlEncOutputChunk ( xmlCharEncodingHandler handler,
unsigned char out,
int outlen,
const unsigned char in,
int inlen 
)
static

Definition at line 1946 of file encoding.c.

1947  {
1948  int ret;
1949 
1950  if (handler->output != NULL) {
1951  ret = handler->output(out, outlen, in, inlen);
1952  }
1953 #ifdef LIBXML_ICONV_ENABLED
1954  else if (handler->iconv_out != NULL) {
1955  ret = xmlIconvWrapper(handler->iconv_out, out, outlen, in, inlen);
1956  }
1957 #endif /* LIBXML_ICONV_ENABLED */
1958 #ifdef LIBXML_ICU_ENABLED
1959  else if (handler->uconv_out != NULL) {
1960  ret = xmlUconvWrapper(handler->uconv_out, 0, out, outlen, in, inlen,
1961  TRUE);
1962  }
1963 #endif /* LIBXML_ICU_ENABLED */
1964  else {
1965  *outlen = 0;
1966  *inlen = 0;
1967  ret = -4;
1968  }
1969 
1970  return(ret);
1971 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int ret
GLuint in
Definition: glext.h:9616
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

Referenced by xmlByteConsumed(), and xmlCharEncOutFunc().

◆ xmlFindCharEncodingHandler()

xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler ( const char name)

Definition at line 1641 of file encoding.c.

1641  {
1642  const char *nalias;
1643  const char *norig;
1645 #ifdef LIBXML_ICONV_ENABLED
1647  iconv_t icv_in, icv_out;
1648 #endif /* LIBXML_ICONV_ENABLED */
1649 #ifdef LIBXML_ICU_ENABLED
1651  uconv_t *ucv_in, *ucv_out;
1652 #endif /* LIBXML_ICU_ENABLED */
1653  char upper[100];
1654  int i;
1655 
1657  if (name == NULL) return(xmlDefaultCharEncodingHandler);
1658  if (name[0] == 0) return(xmlDefaultCharEncodingHandler);
1659 
1660  /*
1661  * Do the alias resolution
1662  */
1663  norig = name;
1664  nalias = xmlGetEncodingAlias(name);
1665  if (nalias != NULL)
1666  name = nalias;
1667 
1668  /*
1669  * Check first for directly registered encoding names
1670  */
1671  for (i = 0;i < 99;i++) {
1672  upper[i] = toupper(name[i]);
1673  if (upper[i] == 0) break;
1674  }
1675  upper[i] = 0;
1676 
1677  if (handlers != NULL) {
1678  for (i = 0;i < nbCharEncodingHandler; i++) {
1679  if (!strcmp(upper, handlers[i]->name)) {
1680 #ifdef DEBUG_ENCODING
1682  "Found registered handler for encoding %s\n", name);
1683 #endif
1684  return(handlers[i]);
1685  }
1686  }
1687  }
1688 
1689 #ifdef LIBXML_ICONV_ENABLED
1690  /* check whether iconv can handle this */
1691  icv_in = iconv_open("UTF-8", name);
1692  icv_out = iconv_open(name, "UTF-8");
1693  if (icv_in == (iconv_t) -1) {
1694  icv_in = iconv_open("UTF-8", upper);
1695  }
1696  if (icv_out == (iconv_t) -1) {
1697  icv_out = iconv_open(upper, "UTF-8");
1698  }
1699  if ((icv_in != (iconv_t) -1) && (icv_out != (iconv_t) -1)) {
1702  if (enc == NULL) {
1703  iconv_close(icv_in);
1704  iconv_close(icv_out);
1705  return(NULL);
1706  }
1707  memset(enc, 0, sizeof(xmlCharEncodingHandler));
1708  enc->name = xmlMemStrdup(name);
1709  enc->input = NULL;
1710  enc->output = NULL;
1711  enc->iconv_in = icv_in;
1712  enc->iconv_out = icv_out;
1713 #ifdef DEBUG_ENCODING
1715  "Found iconv handler for encoding %s\n", name);
1716 #endif
1717  return enc;
1718  } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
1719  xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
1720  "iconv : problems with filters for '%s'\n", name);
1721  }
1722 #endif /* LIBXML_ICONV_ENABLED */
1723 #ifdef LIBXML_ICU_ENABLED
1724  /* check whether icu can handle this */
1725  ucv_in = openIcuConverter(name, 1);
1726  ucv_out = openIcuConverter(name, 0);
1727  if (ucv_in != NULL && ucv_out != NULL) {
1728  encu = (xmlCharEncodingHandlerPtr)
1730  if (encu == NULL) {
1731  closeIcuConverter(ucv_in);
1732  closeIcuConverter(ucv_out);
1733  return(NULL);
1734  }
1735  memset(encu, 0, sizeof(xmlCharEncodingHandler));
1736  encu->name = xmlMemStrdup(name);
1737  encu->input = NULL;
1738  encu->output = NULL;
1739  encu->uconv_in = ucv_in;
1740  encu->uconv_out = ucv_out;
1741 #ifdef DEBUG_ENCODING
1743  "Found ICU converter handler for encoding %s\n", name);
1744 #endif
1745  return encu;
1746  } else if (ucv_in != NULL || ucv_out != NULL) {
1747  closeIcuConverter(ucv_in);
1748  closeIcuConverter(ucv_out);
1749  xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
1750  "ICU converter : problems with filters for '%s'\n", name);
1751  }
1752 #endif /* LIBXML_ICU_ENABLED */
1753 
1754 #ifdef DEBUG_ENCODING
1756  "No handler found for encoding %s\n", name);
1757 #endif
1758 
1759  /*
1760  * Fallback using the canonical names
1761  */
1762  alias = xmlParseCharEncoding(norig);
1763  if (alias != XML_CHAR_ENCODING_ERROR) {
1764  const char* canon;
1765  canon = xmlGetCharEncodingName(alias);
1766  if ((canon != NULL) && (strcmp(name, canon))) {
1767  return(xmlFindCharEncodingHandler(canon));
1768  }
1769  }
1770 
1771  /* If "none of the above", give up */
1772  return(NULL);
1773 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1297
void xmlInitCharEncodingHandlers(void)
Definition: encoding.c:1397
xmlCharEncoding
Definition: encoding.h:58
static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler
Definition: encoding.c:1305
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1641
xmlCharEncodingOutputFunc output
Definition: encoding.h:149
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
xmlCharEncodingInputFunc input
Definition: encoding.h:148
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
int toupper(int c)
Definition: utclib.c:881
iconv_t iconv_open(const char *tocode, const char *fromcode)
Definition: win_iconv.c:730
const char * xmlGetEncodingAlias(const char *alias)
Definition: encoding.c:1019
const WCHAR * alias
Definition: main.c:67
static int nbCharEncodingHandler
Definition: encoding.c:1298
XMLPUBVAR xmlStrdupFunc xmlMemStrdup
Definition: globals.h:251
xmlCharEncodingHandler * xmlCharEncodingHandlerPtr
Definition: encoding.h:145
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
xmlCharEncoding xmlParseCharEncoding(const char *name)
Definition: encoding.c:1150
int iconv_close(iconv_t cd)
Definition: win_iconv.c:756
#define memset(x, y, z)
Definition: compat.h:39
const char * xmlGetCharEncodingName(xmlCharEncoding enc)
Definition: encoding.c:1234
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xmlCtxtResetPush(), xmlDoRead(), xmlGetCharEncodingHandler(), xmlParseEncodingDecl(), xmlParseInNodeContext(), xsltSaveResultToFd(), xsltSaveResultToFile(), xsltSaveResultToFilename(), and xsltSaveResultToString().

◆ xmlGetCharEncodingHandler()

xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler ( xmlCharEncoding  enc)

xmlGetCharEncodingHandler: @enc: an xmlCharEncoding value.

Search in the registered set the handler able to read/write that encoding.

Returns the handler or NULL if not found

Definition at line 1507 of file encoding.c.

1507  {
1509 
1511  switch (enc) {
1513  return(NULL);
1515  return(NULL);
1517  return(NULL);
1519  return(xmlUTF16LEHandler);
1521  return(xmlUTF16BEHandler);
1523  handler = xmlFindCharEncodingHandler("EBCDIC");
1524  if (handler != NULL) return(handler);
1525  handler = xmlFindCharEncodingHandler("ebcdic");
1526  if (handler != NULL) return(handler);
1527  handler = xmlFindCharEncodingHandler("EBCDIC-US");
1528  if (handler != NULL) return(handler);
1529  handler = xmlFindCharEncodingHandler("IBM-037");
1530  if (handler != NULL) return(handler);
1531  break;
1533  handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
1534  if (handler != NULL) return(handler);
1536  if (handler != NULL) return(handler);
1538  if (handler != NULL) return(handler);
1539  break;
1541  handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
1542  if (handler != NULL) return(handler);
1544  if (handler != NULL) return(handler);
1546  if (handler != NULL) return(handler);
1547  break;
1549  break;
1551  break;
1553  handler = xmlFindCharEncodingHandler("ISO-10646-UCS-2");
1554  if (handler != NULL) return(handler);
1556  if (handler != NULL) return(handler);
1558  if (handler != NULL) return(handler);
1559  break;
1560 
1561  /*
1562  * We used to keep ISO Latin encodings native in the
1563  * generated data. This led to so many problems that
1564  * this has been removed. One can still change this
1565  * back by registering no-ops encoders for those
1566  */
1568  handler = xmlFindCharEncodingHandler("ISO-8859-1");
1569  if (handler != NULL) return(handler);
1570  break;
1572  handler = xmlFindCharEncodingHandler("ISO-8859-2");
1573  if (handler != NULL) return(handler);
1574  break;
1576  handler = xmlFindCharEncodingHandler("ISO-8859-3");
1577  if (handler != NULL) return(handler);
1578  break;
1580  handler = xmlFindCharEncodingHandler("ISO-8859-4");
1581  if (handler != NULL) return(handler);
1582  break;
1584  handler = xmlFindCharEncodingHandler("ISO-8859-5");
1585  if (handler != NULL) return(handler);
1586  break;
1588  handler = xmlFindCharEncodingHandler("ISO-8859-6");
1589  if (handler != NULL) return(handler);
1590  break;
1592  handler = xmlFindCharEncodingHandler("ISO-8859-7");
1593  if (handler != NULL) return(handler);
1594  break;
1596  handler = xmlFindCharEncodingHandler("ISO-8859-8");
1597  if (handler != NULL) return(handler);
1598  break;
1600  handler = xmlFindCharEncodingHandler("ISO-8859-9");
1601  if (handler != NULL) return(handler);
1602  break;
1603 
1604 
1606  handler = xmlFindCharEncodingHandler("ISO-2022-JP");
1607  if (handler != NULL) return(handler);
1608  break;
1610  handler = xmlFindCharEncodingHandler("SHIFT-JIS");
1611  if (handler != NULL) return(handler);
1612  handler = xmlFindCharEncodingHandler("SHIFT_JIS");
1613  if (handler != NULL) return(handler);
1614  handler = xmlFindCharEncodingHandler("Shift_JIS");
1615  if (handler != NULL) return(handler);
1616  break;
1618  handler = xmlFindCharEncodingHandler("EUC-JP");
1619  if (handler != NULL) return(handler);
1620  break;
1621  default:
1622  break;
1623  }
1624 
1625 #ifdef DEBUG_ENCODING
1627  "No handler found for encoding %d\n", enc);
1628 #endif
1629  return(NULL);
1630 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1297
void xmlInitCharEncodingHandlers(void)
Definition: encoding.c:1397
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler
Definition: encoding.c:52
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1641
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler
Definition: encoding.c:51
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlSwitchEncoding().

◆ xmlGetCharEncodingName()

const char* xmlGetCharEncodingName ( xmlCharEncoding  enc)

xmlGetCharEncodingName: @enc: the encoding

The "canonical" name for XML encoding. C.f. http://www.w3.org/TR/REC-xml#charencoding Section 4.3.3 Character Encoding in Entities

Returns the canonical name for the given encoding

Definition at line 1234 of file encoding.c.

1234  {
1235  switch (enc) {
1237  return(NULL);
1239  return(NULL);
1241  return("UTF-8");
1243  return("UTF-16");
1245  return("UTF-16");
1247  return("EBCDIC");
1249  return("ISO-10646-UCS-4");
1251  return("ISO-10646-UCS-4");
1253  return("ISO-10646-UCS-4");
1255  return("ISO-10646-UCS-4");
1257  return("ISO-10646-UCS-2");
1259  return("ISO-8859-1");
1261  return("ISO-8859-2");
1263  return("ISO-8859-3");
1265  return("ISO-8859-4");
1267  return("ISO-8859-5");
1269  return("ISO-8859-6");
1271  return("ISO-8859-7");
1273  return("ISO-8859-8");
1275  return("ISO-8859-9");
1277  return("ISO-2022-JP");
1279  return("Shift-JIS");
1281  return("EUC-JP");
1283  return(NULL);
1284  }
1285  return(NULL);
1286 }
smooth NULL
Definition: ftsmooth.c:416

Referenced by xmlFindCharEncodingHandler(), and xsltSaveResultTo().

◆ xmlGetEncodingAlias()

const char* xmlGetEncodingAlias ( const char alias)

xmlGetEncodingAlias: @alias: the alias name as parsed, in UTF-8 format (ASCII actually)

Lookup an encoding name for the given alias.

Returns NULL if not found, otherwise the original name

Definition at line 1019 of file encoding.c.

1019  {
1020  int i;
1021  char upper[100];
1022 
1023  if (alias == NULL)
1024  return(NULL);
1025 
1027  return(NULL);
1028 
1029  for (i = 0;i < 99;i++) {
1030  upper[i] = toupper(alias[i]);
1031  if (upper[i] == 0) break;
1032  }
1033  upper[i] = 0;
1034 
1035  /*
1036  * Walk down the list looking for a definition of the alias
1037  */
1038  for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
1039  if (!strcmp(xmlCharEncodingAliases[i].alias, upper)) {
1040  return(xmlCharEncodingAliases[i].name);
1041  }
1042  }
1043  return(NULL);
1044 }
static xmlCharEncodingAliasPtr xmlCharEncodingAliases
Definition: encoding.c:61
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
int toupper(int c)
Definition: utclib.c:881
static int xmlCharEncodingAliasesNb
Definition: encoding.c:62
const WCHAR * alias
Definition: main.c:67
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by xmlFindCharEncodingHandler(), xmlNewCharEncodingHandler(), and xmlParseCharEncoding().

◆ xmlInitCharEncodingHandlers()

void xmlInitCharEncodingHandlers ( void  )

xmlInitCharEncodingHandlers:

Initialize the char encoding support, it registers the default encoding supported. NOTE: while public, this function usually doesn't need to be called in normal processing.

Definition at line 1397 of file encoding.c.

1397  {
1398  unsigned short int tst = 0x1234;
1399  unsigned char *ptr = (unsigned char *) &tst;
1400 
1401  if (handlers != NULL) return;
1402 
1405 
1406  if (*ptr == 0x12) xmlLittleEndian = 0;
1407  else if (*ptr == 0x34) xmlLittleEndian = 1;
1408  else {
1409  xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
1410  "Odd problem at endianness detection\n", NULL);
1411  }
1412 
1413  if (handlers == NULL) {
1414  xmlEncodingErrMemory("xmlInitCharEncodingHandlers : out of memory !\n");
1415  return;
1416  }
1418 #ifdef LIBXML_OUTPUT_ENABLED
1420  xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE);
1422  xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, UTF8ToUTF16BE);
1423  xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, UTF8ToUTF16);
1424  xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1);
1425  xmlNewCharEncodingHandler("ASCII", asciiToUTF8, UTF8Toascii);
1426  xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, UTF8Toascii);
1427 #ifdef LIBXML_HTML_ENABLED
1428  xmlNewCharEncodingHandler("HTML", NULL, UTF8ToHtml);
1429 #endif
1430 #else
1439 #endif /* LIBXML_OUTPUT_ENABLED */
1440 #if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
1441 #ifdef LIBXML_ISO8859X_ENABLED
1442  xmlRegisterCharEncodingHandlersISO8859x ();
1443 #endif
1444 #endif
1445 
1446 }
static void xmlEncodingErrMemory(const char *extra)
Definition: encoding.c:84
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1297
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler
Definition: encoding.c:52
static int asciiToUTF8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
Definition: encoding.c:176
static int UTF16BEToUTF8(unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
Definition: encoding.c:732
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler
Definition: encoding.c:51
static int UTF16LEToUTF8(unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
Definition: encoding.c:494
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
#define MAX_ENCODING_HANDLERS
Definition: encoding.c:1296
static int xmlLittleEndian
Definition: encoding.c:75
xmlCharEncodingHandlerPtr xmlNewCharEncodingHandler(const char *name, xmlCharEncodingInputFunc input, xmlCharEncodingOutputFunc output)
Definition: encoding.c:1318
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
static int UTF8ToUTF8(unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
Definition: encoding.c:355
int isolat1ToUTF8(unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
Definition: encoding.c:307

Referenced by xmlFindCharEncodingHandler(), xmlGetCharEncodingHandler(), xmlInitParser(), and xmlRegisterCharEncodingHandler().

◆ xmlNewCharEncodingHandler()

xmlCharEncodingHandlerPtr xmlNewCharEncodingHandler ( const char name,
xmlCharEncodingInputFunc  input,
xmlCharEncodingOutputFunc  output 
)

Definition at line 1318 of file encoding.c.

1320  {
1322  const char *alias;
1323  char upper[500];
1324  int i;
1325  char *up = NULL;
1326 
1327  /*
1328  * Do the alias resolution
1329  */
1331  if (alias != NULL)
1332  name = alias;
1333 
1334  /*
1335  * Keep only the uppercase version of the encoding.
1336  */
1337  if (name == NULL) {
1338  xmlEncodingErr(XML_I18N_NO_NAME,
1339  "xmlNewCharEncodingHandler : no name !\n", NULL);
1340  return(NULL);
1341  }
1342  for (i = 0;i < 499;i++) {
1343  upper[i] = toupper(name[i]);
1344  if (upper[i] == 0) break;
1345  }
1346  upper[i] = 0;
1347  up = xmlMemStrdup(upper);
1348  if (up == NULL) {
1349  xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
1350  return(NULL);
1351  }
1352 
1353  /*
1354  * allocate and fill-up an handler block.
1355  */
1358  if (handler == NULL) {
1359  xmlFree(up);
1360  xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
1361  return(NULL);
1362  }
1363  memset(handler, 0, sizeof(xmlCharEncodingHandler));
1364  handler->input = input;
1365  handler->output = output;
1366  handler->name = up;
1367 
1368 #ifdef LIBXML_ICONV_ENABLED
1369  handler->iconv_in = NULL;
1370  handler->iconv_out = NULL;
1371 #endif
1372 #ifdef LIBXML_ICU_ENABLED
1373  handler->uconv_in = NULL;
1374  handler->uconv_out = NULL;
1375 #endif
1376 
1377  /*
1378  * registers and returns the handler.
1379  */
1381 #ifdef DEBUG_ENCODING
1383  "Registered encoding handler for %s\n", name);
1384 #endif
1385  return(handler);
1386 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
static void xmlEncodingErrMemory(const char *extra)
Definition: encoding.c:84
#define up(mutex)
Definition: glue.h:30
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
int toupper(int c)
Definition: utclib.c:881
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
const char * xmlGetEncodingAlias(const char *alias)
Definition: encoding.c:1019
const WCHAR * alias
Definition: main.c:67
void xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler)
Definition: encoding.c:1481
XMLPUBVAR xmlStrdupFunc xmlMemStrdup
Definition: globals.h:251
GLenum GLenum GLenum input
Definition: glext.h:9031
xmlCharEncodingHandler * xmlCharEncodingHandlerPtr
Definition: encoding.h:145
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:36
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
#define memset(x, y, z)
Definition: compat.h:39
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlInitCharEncodingHandlers().

◆ xmlParseCharEncoding()

xmlCharEncoding xmlParseCharEncoding ( const char name)

Definition at line 1150 of file encoding.c.

1151 {
1152  const char *alias;
1153  char upper[500];
1154  int i;
1155 
1156  if (name == NULL)
1157  return(XML_CHAR_ENCODING_NONE);
1158 
1159  /*
1160  * Do the alias resolution
1161  */
1163  if (alias != NULL)
1164  name = alias;
1165 
1166  for (i = 0;i < 499;i++) {
1167  upper[i] = toupper(name[i]);
1168  if (upper[i] == 0) break;
1169  }
1170  upper[i] = 0;
1171 
1172  if (!strcmp(upper, "")) return(XML_CHAR_ENCODING_NONE);
1173  if (!strcmp(upper, "UTF-8")) return(XML_CHAR_ENCODING_UTF8);
1174  if (!strcmp(upper, "UTF8")) return(XML_CHAR_ENCODING_UTF8);
1175 
1176  /*
1177  * NOTE: if we were able to parse this, the endianness of UTF16 is
1178  * already found and in use
1179  */
1180  if (!strcmp(upper, "UTF-16")) return(XML_CHAR_ENCODING_UTF16LE);
1181  if (!strcmp(upper, "UTF16")) return(XML_CHAR_ENCODING_UTF16LE);
1182 
1183  if (!strcmp(upper, "ISO-10646-UCS-2")) return(XML_CHAR_ENCODING_UCS2);
1184  if (!strcmp(upper, "UCS-2")) return(XML_CHAR_ENCODING_UCS2);
1185  if (!strcmp(upper, "UCS2")) return(XML_CHAR_ENCODING_UCS2);
1186 
1187  /*
1188  * NOTE: if we were able to parse this, the endianness of UCS4 is
1189  * already found and in use
1190  */
1191  if (!strcmp(upper, "ISO-10646-UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
1192  if (!strcmp(upper, "UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
1193  if (!strcmp(upper, "UCS4")) return(XML_CHAR_ENCODING_UCS4LE);
1194 
1195 
1196  if (!strcmp(upper, "ISO-8859-1")) return(XML_CHAR_ENCODING_8859_1);
1197  if (!strcmp(upper, "ISO-LATIN-1")) return(XML_CHAR_ENCODING_8859_1);
1198  if (!strcmp(upper, "ISO LATIN 1")) return(XML_CHAR_ENCODING_8859_1);
1199 
1200  if (!strcmp(upper, "ISO-8859-2")) return(XML_CHAR_ENCODING_8859_2);
1201  if (!strcmp(upper, "ISO-LATIN-2")) return(XML_CHAR_ENCODING_8859_2);
1202  if (!strcmp(upper, "ISO LATIN 2")) return(XML_CHAR_ENCODING_8859_2);
1203 
1204  if (!strcmp(upper, "ISO-8859-3")) return(XML_CHAR_ENCODING_8859_3);
1205  if (!strcmp(upper, "ISO-8859-4")) return(XML_CHAR_ENCODING_8859_4);
1206  if (!strcmp(upper, "ISO-8859-5")) return(XML_CHAR_ENCODING_8859_5);
1207  if (!strcmp(upper, "ISO-8859-6")) return(XML_CHAR_ENCODING_8859_6);
1208  if (!strcmp(upper, "ISO-8859-7")) return(XML_CHAR_ENCODING_8859_7);
1209  if (!strcmp(upper, "ISO-8859-8")) return(XML_CHAR_ENCODING_8859_8);
1210  if (!strcmp(upper, "ISO-8859-9")) return(XML_CHAR_ENCODING_8859_9);
1211 
1212  if (!strcmp(upper, "ISO-2022-JP")) return(XML_CHAR_ENCODING_2022_JP);
1213  if (!strcmp(upper, "SHIFT_JIS")) return(XML_CHAR_ENCODING_SHIFT_JIS);
1214  if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
1215 
1216 #ifdef DEBUG_ENCODING
1217  xmlGenericError(xmlGenericErrorContext, "Unknown encoding %s\n", name);
1218 #endif
1219  return(XML_CHAR_ENCODING_ERROR);
1220 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
int toupper(int c)
Definition: utclib.c:881
const char * xmlGetEncodingAlias(const char *alias)
Definition: encoding.c:1019
const WCHAR * alias
Definition: main.c:67
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlFindCharEncodingHandler().

◆ xmlRegisterCharEncodingHandler()

void xmlRegisterCharEncodingHandler ( xmlCharEncodingHandlerPtr  handler)

xmlRegisterCharEncodingHandler: @handler: the xmlCharEncodingHandlerPtr handler block

Register the char encoding handler, surprising, isn't it ?

Definition at line 1481 of file encoding.c.

1481  {
1483  if ((handler == NULL) || (handlers == NULL)) {
1484  xmlEncodingErr(XML_I18N_NO_HANDLER,
1485  "xmlRegisterCharEncodingHandler: NULL handler !\n", NULL);
1486  return;
1487  }
1488 
1490  xmlEncodingErr(XML_I18N_EXCESS_HANDLER,
1491  "xmlRegisterCharEncodingHandler: Too many handler registered, see %s\n",
1492  "MAX_ENCODING_HANDLERS");
1493  return;
1494  }
1496 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1297
void xmlInitCharEncodingHandlers(void)
Definition: encoding.c:1397
smooth NULL
Definition: ftsmooth.c:416
#define MAX_ENCODING_HANDLERS
Definition: encoding.c:1296
static int nbCharEncodingHandler
Definition: encoding.c:1298
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

Referenced by xmlNewCharEncodingHandler().

Variable Documentation

◆ handlers

◆ nbCharEncodingHandler

int nbCharEncodingHandler = 0
static

◆ xmlCharEncodingAliases

xmlCharEncodingAliasPtr xmlCharEncodingAliases = NULL
static

◆ xmlCharEncodingAliasesMax

int xmlCharEncodingAliasesMax = 0
static

Definition at line 63 of file encoding.c.

Referenced by xmlAddEncodingAlias(), and xmlCleanupEncodingAliases().

◆ xmlCharEncodingAliasesNb

int xmlCharEncodingAliasesNb = 0
static

◆ xmlDefaultCharEncodingHandler

xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL
static

Definition at line 1305 of file encoding.c.

Referenced by xmlCleanupCharEncodingHandlers(), and xmlFindCharEncodingHandler().

◆ xmlLittleEndian

int xmlLittleEndian = 1
static

Definition at line 75 of file encoding.c.

Referenced by UTF16BEToUTF8(), UTF16LEToUTF8(), and xmlInitCharEncodingHandlers().

◆ xmlUTF16BEHandler

xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL
static

Definition at line 52 of file encoding.c.

Referenced by xmlGetCharEncodingHandler(), and xmlInitCharEncodingHandlers().

◆ xmlUTF16LEHandler

xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL
static

Definition at line 51 of file encoding.c.

Referenced by xmlGetCharEncodingHandler(), and xmlInitCharEncodingHandlers().