ReactOS  0.4.15-dev-3291-gea4c1a0
encoding.h File Reference
#include <libxml/xmlversion.h>
#include <libxml/tree.h>
Include dependency graph for encoding.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _xmlCharEncodingHandler
 

Typedefs

typedef int(* xmlCharEncodingInputFunc) (unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
 
typedef int(* xmlCharEncodingOutputFunc) (unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
 
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler
 
typedef xmlCharEncodingHandlerxmlCharEncodingHandlerPtr
 

Enumerations

enum  xmlCharEncoding {
  XML_CHAR_ENCODING_ERROR = -1, XML_CHAR_ENCODING_NONE = 0, XML_CHAR_ENCODING_UTF8 = 1, XML_CHAR_ENCODING_UTF16LE = 2,
  XML_CHAR_ENCODING_UTF16BE = 3, XML_CHAR_ENCODING_UCS4LE = 4, XML_CHAR_ENCODING_UCS4BE = 5, XML_CHAR_ENCODING_EBCDIC = 6,
  XML_CHAR_ENCODING_UCS4_2143 =7, XML_CHAR_ENCODING_UCS4_3412 =8, XML_CHAR_ENCODING_UCS2 = 9, XML_CHAR_ENCODING_8859_1 = 10,
  XML_CHAR_ENCODING_8859_2 = 11, XML_CHAR_ENCODING_8859_3 = 12, XML_CHAR_ENCODING_8859_4 = 13, XML_CHAR_ENCODING_8859_5 = 14,
  XML_CHAR_ENCODING_8859_6 = 15, XML_CHAR_ENCODING_8859_7 = 16, XML_CHAR_ENCODING_8859_8 = 17, XML_CHAR_ENCODING_8859_9 = 18,
  XML_CHAR_ENCODING_2022_JP = 19, XML_CHAR_ENCODING_SHIFT_JIS =20, XML_CHAR_ENCODING_EUC_JP = 21, XML_CHAR_ENCODING_ASCII = 22
}
 

Functions

XMLPUBFUN void XMLCALL xmlInitCharEncodingHandlers (void)
 
XMLPUBFUN void XMLCALL xmlCleanupCharEncodingHandlers (void)
 
XMLPUBFUN void XMLCALL xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler)
 
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlGetCharEncodingHandler (xmlCharEncoding enc)
 
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler (const char *name)
 
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlNewCharEncodingHandler (const char *name, xmlCharEncodingInputFunc input, xmlCharEncodingOutputFunc output)
 
XMLPUBFUN int XMLCALL xmlAddEncodingAlias (const char *name, const char *alias)
 
XMLPUBFUN int XMLCALL xmlDelEncodingAlias (const char *alias)
 
XMLPUBFUN const char *XMLCALL xmlGetEncodingAlias (const char *alias)
 
XMLPUBFUN void XMLCALL xmlCleanupEncodingAliases (void)
 
XMLPUBFUN xmlCharEncoding XMLCALL xmlParseCharEncoding (const char *name)
 
XMLPUBFUN const char *XMLCALL xmlGetCharEncodingName (xmlCharEncoding enc)
 
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding (const unsigned char *in, int len)
 
XMLPUBFUN int XMLCALL xmlCharEncOutFunc (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in)
 
XMLPUBFUN int XMLCALL xmlCharEncInFunc (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in)
 
XMLPUBFUN int XMLCALL xmlCharEncFirstLine (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in)
 
XMLPUBFUN int XMLCALL xmlCharEncCloseFunc (xmlCharEncodingHandler *handler)
 
XMLPUBFUN int XMLCALL isolat1ToUTF8 (unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
 

Typedef Documentation

◆ xmlCharEncodingHandler

◆ xmlCharEncodingHandlerPtr

Definition at line 145 of file encoding.h.

◆ xmlCharEncodingInputFunc

typedef int(* xmlCharEncodingInputFunc) (unsigned char *out, int *outlen, const unsigned char *in, int *inlen)

xmlCharEncodingInputFunc: @out: a pointer to an array of bytes to store the UTF-8 result @outlen: the length of @out @in: a pointer to an array of chars in the original encoding @inlen: the length of @in

Take a block of chars in the original encoding and try to convert it to an UTF-8 block of chars out.

Returns the number of bytes written, -1 if lack of space, or -2 if the transcoding failed. The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictiable. The value of @outlen after return is the number of octets consumed.

Definition at line 101 of file encoding.h.

◆ xmlCharEncodingOutputFunc

typedef int(* xmlCharEncodingOutputFunc) (unsigned char *out, int *outlen, const unsigned char *in, int *inlen)

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

Take a block of UTF-8 chars in and try to convert it to another encoding. Note: a first call designed to produce heading info is called with in = NULL. If stateful this should also initialize the encoder state.

Returns the number of bytes written, -1 if lack of space, or -2 if the transcoding failed. The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictiable. The value of @outlen after return is the number of octets produced.

Definition at line 123 of file encoding.h.

Enumeration Type Documentation

◆ xmlCharEncoding

Enumerator
XML_CHAR_ENCODING_ERROR 
XML_CHAR_ENCODING_NONE 
XML_CHAR_ENCODING_UTF8 
XML_CHAR_ENCODING_UTF16LE 
XML_CHAR_ENCODING_UTF16BE 
XML_CHAR_ENCODING_UCS4LE 
XML_CHAR_ENCODING_UCS4BE 
XML_CHAR_ENCODING_EBCDIC 
XML_CHAR_ENCODING_UCS4_2143 
XML_CHAR_ENCODING_UCS4_3412 
XML_CHAR_ENCODING_UCS2 
XML_CHAR_ENCODING_8859_1 
XML_CHAR_ENCODING_8859_2 
XML_CHAR_ENCODING_8859_3 
XML_CHAR_ENCODING_8859_4 
XML_CHAR_ENCODING_8859_5 
XML_CHAR_ENCODING_8859_6 
XML_CHAR_ENCODING_8859_7 
XML_CHAR_ENCODING_8859_8 
XML_CHAR_ENCODING_8859_9 
XML_CHAR_ENCODING_2022_JP 
XML_CHAR_ENCODING_SHIFT_JIS 
XML_CHAR_ENCODING_EUC_JP 
XML_CHAR_ENCODING_ASCII 

Definition at line 58 of file encoding.h.

58  {
59  XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
60  XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
61  XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
62  XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
63  XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
64  XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
65  XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
66  XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
67  XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
68  XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
69  XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
70  XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
71  XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
72  XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
73  XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
74  XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
75  XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
76  XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
77  XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
78  XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
79  XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
80  XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
81  XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
82  XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
xmlCharEncoding
Definition: encoding.h:58

Function Documentation

◆ isolat1ToUTF8()

XMLPUBFUN int XMLCALL 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 produced.

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
static FILE * out
Definition: regtests2xml.c:44
GLuint in
Definition: glext.h:9616
#define NULL
Definition: types.h:112

Referenced by xmlInitCharEncodingHandlers().

◆ xmlAddEncodingAlias()

XMLPUBFUN int XMLCALL xmlAddEncodingAlias ( const char name,
const char alias 
)

Definition at line 1067 of file encoding.c.

1067  {
1068  int i;
1069  char upper[100];
1070 
1071  if ((name == NULL) || (alias == NULL))
1072  return(-1);
1073 
1074  for (i = 0;i < 99;i++) {
1075  upper[i] = toupper(alias[i]);
1076  if (upper[i] == 0) break;
1077  }
1078  upper[i] = 0;
1079 
1080  if (xmlCharEncodingAliases == NULL) {
1086  return(-1);
1092  }
1093  /*
1094  * Walk down the list looking for a definition of the alias
1095  */
1096  for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
1097  if (!strcmp(xmlCharEncodingAliases[i].alias, upper)) {
1098  /*
1099  * Replace the definition.
1100  */
1101  xmlFree((char *) xmlCharEncodingAliases[i].name);
1103  return(0);
1104  }
1105  }
1106  /*
1107  * Add the definition
1108  */
1112  return(0);
1113 }
const char * name
Definition: encoding.c:57
static xmlCharEncodingAliasPtr xmlCharEncodingAliases
Definition: encoding.c:61
static int xmlCharEncodingAliasesMax
Definition: encoding.c:63
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
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
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by main().

◆ xmlCharEncCloseFunc()

XMLPUBFUN int XMLCALL xmlCharEncCloseFunc ( xmlCharEncodingHandler handler)

xmlCharEncCloseFunc: @handler: char encoding transformation data structure

Generic front-end for encoding handler close function

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

Definition at line 2780 of file encoding.c.

2780  {
2781  int ret = 0;
2782  int tofree = 0;
2783  int i, handler_in_list = 0;
2784 
2785  if (handler == NULL) return(-1);
2786  if (handler->name == NULL) return(-1);
2787  if (handlers != NULL) {
2788  for (i = 0;i < nbCharEncodingHandler; i++) {
2789  if (handler == handlers[i]) {
2790  handler_in_list = 1;
2791  break;
2792  }
2793  }
2794  }
2795 #ifdef LIBXML_ICONV_ENABLED
2796  /*
2797  * Iconv handlers can be used only once, free the whole block.
2798  * and the associated icon resources.
2799  */
2800  if ((handler_in_list == 0) &&
2801  ((handler->iconv_out != NULL) || (handler->iconv_in != NULL))) {
2802  tofree = 1;
2803  if (handler->iconv_out != NULL) {
2804  if (iconv_close(handler->iconv_out))
2805  ret = -1;
2806  handler->iconv_out = NULL;
2807  }
2808  if (handler->iconv_in != NULL) {
2809  if (iconv_close(handler->iconv_in))
2810  ret = -1;
2811  handler->iconv_in = NULL;
2812  }
2813  }
2814 #endif /* LIBXML_ICONV_ENABLED */
2815 #ifdef LIBXML_ICU_ENABLED
2816  if ((handler_in_list == 0) &&
2817  ((handler->uconv_out != NULL) || (handler->uconv_in != NULL))) {
2818  tofree = 1;
2819  if (handler->uconv_out != NULL) {
2820  closeIcuConverter(handler->uconv_out);
2821  handler->uconv_out = NULL;
2822  }
2823  if (handler->uconv_in != NULL) {
2824  closeIcuConverter(handler->uconv_in);
2825  handler->uconv_in = NULL;
2826  }
2827  }
2828 #endif
2829  if (tofree) {
2830  /* free up only dynamic handlers iconv/uconv */
2831  if (handler->name != NULL)
2832  xmlFree(handler->name);
2833  handler->name = NULL;
2834  xmlFree(handler);
2835  }
2836 #ifdef DEBUG_ENCODING
2837  if (ret)
2839  "failed to close the encoding handler\n");
2840  else
2842  "closed the encoding handler\n");
2843 #endif
2844 
2845  return(ret);
2846 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1307
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
int ret
static int nbCharEncodingHandler
Definition: encoding.c:1308
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
#define NULL
Definition: types.h:112
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()

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

xmlCharEncFirstLine: @handler: char encoding 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 2135 of file encoding.c.

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

◆ xmlCharEncInFunc()

XMLPUBFUN int XMLCALL 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 2362 of file encoding.c.

2364 {
2365  int ret;
2366  int written;
2367  int toconv;
2368 
2369  if (handler == NULL)
2370  return (-1);
2371  if (out == NULL)
2372  return (-1);
2373  if (in == NULL)
2374  return (-1);
2375 
2376  toconv = in->use;
2377  if (toconv == 0)
2378  return (0);
2379  written = out->size - out->use -1; /* count '\0' */
2380  if (toconv * 2 >= written) {
2381  xmlBufferGrow(out, out->size + toconv * 2);
2382  written = out->size - out->use - 1;
2383  }
2384  ret = xmlEncInputChunk(handler, &out->content[out->use], &written,
2385  in->content, &toconv, 1);
2386  xmlBufferShrink(in, toconv);
2387  out->use += written;
2388  out->content[out->use] = 0;
2389  if (ret == -1)
2390  ret = -3;
2391 
2392  switch (ret) {
2393  case 0:
2394 #ifdef DEBUG_ENCODING
2396  "converted %d bytes to %d bytes of input\n",
2397  toconv, written);
2398 #endif
2399  break;
2400  case -1:
2401 #ifdef DEBUG_ENCODING
2403  "converted %d bytes to %d bytes of input, %d left\n",
2404  toconv, written, in->use);
2405 #endif
2406  break;
2407  case -3:
2408 #ifdef DEBUG_ENCODING
2410  "converted %d bytes to %d bytes of input, %d left\n",
2411  toconv, written, in->use);
2412 #endif
2413  break;
2414  case -2: {
2415  char buf[50];
2416 
2417  snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
2418  in->content[0], in->content[1],
2419  in->content[2], in->content[3]);
2420  buf[49] = 0;
2421  xmlEncodingErr(XML_I18N_CONV_FAILED,
2422  "input conversion failed due to input error, bytes %s\n",
2423  buf);
2424  }
2425  }
2426  /*
2427  * Ignore when input buffer is not on a boundary
2428  */
2429  if (ret == -3)
2430  ret = 0;
2431  return (written? written : ret);
2432 }
#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:1954
XMLPUBFUN int XMLCALL xmlBufferGrow(xmlBufferPtr buf, unsigned int len)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN int XMLCALL xmlBufferShrink(xmlBufferPtr buf, unsigned int len)
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
static FILE * out
Definition: regtests2xml.c:44
int ret
GLuint in
Definition: glext.h:9616
#define NULL
Definition: types.h:112
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ xmlCharEncOutFunc()

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

xmlCharEncOutFunc: @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 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 2626 of file encoding.c.

2627  {
2628  int ret;
2629  int written;
2630  int writtentot = 0;
2631  int toconv;
2632  int output = 0;
2633 
2634  if (handler == NULL) return(-1);
2635  if (out == NULL) return(-1);
2636 
2637 retry:
2638 
2639  written = out->size - out->use;
2640 
2641  if (written > 0)
2642  written--; /* Gennady: count '/0' */
2643 
2644  /*
2645  * First specific handling of in = NULL, i.e. the initialization call
2646  */
2647  if (in == NULL) {
2648  toconv = 0;
2649  /* TODO: Check return value. */
2650  xmlEncOutputChunk(handler, &out->content[out->use], &written,
2651  NULL, &toconv);
2652  out->use += written;
2653  out->content[out->use] = 0;
2654 #ifdef DEBUG_ENCODING
2656  "initialized encoder\n");
2657 #endif
2658  return(0);
2659  }
2660 
2661  /*
2662  * Conversion itself.
2663  */
2664  toconv = in->use;
2665  if (toconv == 0)
2666  return(0);
2667  if (toconv * 4 >= written) {
2668  xmlBufferGrow(out, toconv * 4);
2669  written = out->size - out->use - 1;
2670  }
2671  ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
2672  in->content, &toconv);
2673  xmlBufferShrink(in, toconv);
2674  out->use += written;
2675  writtentot += written;
2676  out->content[out->use] = 0;
2677  if (ret == -1) {
2678  if (written > 0) {
2679  /* Can be a limitation of iconv or uconv */
2680  goto retry;
2681  }
2682  ret = -3;
2683  }
2684 
2685  if (ret >= 0) output += ret;
2686 
2687  /*
2688  * Attempt to handle error cases
2689  */
2690  switch (ret) {
2691  case 0:
2692 #ifdef DEBUG_ENCODING
2694  "converted %d bytes to %d bytes of output\n",
2695  toconv, written);
2696 #endif
2697  break;
2698  case -1:
2699 #ifdef DEBUG_ENCODING
2701  "output conversion failed by lack of space\n");
2702 #endif
2703  break;
2704  case -3:
2705 #ifdef DEBUG_ENCODING
2706  xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
2707  toconv, written, in->use);
2708 #endif
2709  break;
2710  case -4:
2711  xmlEncodingErr(XML_I18N_NO_OUTPUT,
2712  "xmlCharEncOutFunc: no output function !\n", NULL);
2713  ret = -1;
2714  break;
2715  case -2: {
2716  xmlChar charref[20];
2717  int len = in->use;
2718  const xmlChar *utf = (const xmlChar *) in->content;
2719  int cur, charrefLen;
2720 
2721  cur = xmlGetUTF8Char(utf, &len);
2722  if (cur <= 0)
2723  break;
2724 
2725 #ifdef DEBUG_ENCODING
2727  "handling output conversion error\n");
2729  "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
2730  in->content[0], in->content[1],
2731  in->content[2], in->content[3]);
2732 #endif
2733  /*
2734  * Removes the UTF8 sequence, and replace it by a charref
2735  * and continue the transcoding phase, hoping the error
2736  * did not mangle the encoder state.
2737  */
2738  charrefLen = snprintf((char *) &charref[0], sizeof(charref),
2739  "&#%d;", cur);
2741  xmlBufferGrow(out, charrefLen * 4);
2742  written = out->size - out->use - 1;
2743  toconv = charrefLen;
2744  ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
2745  charref, &toconv);
2746 
2747  if ((ret < 0) || (toconv != charrefLen)) {
2748  char buf[50];
2749 
2750  snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
2751  in->content[0], in->content[1],
2752  in->content[2], in->content[3]);
2753  buf[49] = 0;
2754  xmlEncodingErr(XML_I18N_CONV_FAILED,
2755  "output conversion failed due to conv error, bytes %s\n",
2756  buf);
2757  if (in->alloc != XML_BUFFER_ALLOC_IMMUTABLE)
2758  in->content[0] = ' ';
2759  break;
2760  }
2761 
2762  out->use += written;
2763  writtentot += written;
2764  out->content[out->use] = 0;
2765  goto retry;
2766  }
2767  }
2768  return(writtentot ? writtentot : ret);
2769 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
#define snprintf
Definition: wintirpc.h:48
XMLPUBFUN int XMLCALL xmlBufferGrow(xmlBufferPtr buf, unsigned int len)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static int xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out, int *outlen, const unsigned char *in, int *inlen)
Definition: encoding.c:2004
XMLPUBFUN int XMLCALL xmlBufferShrink(xmlBufferPtr buf, unsigned int len)
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
static FILE * out
Definition: regtests2xml.c:44
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
FxCollectionEntry * cur
GLuint in
Definition: glext.h:9616
#define NULL
Definition: types.h:112
XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL XMLPUBFUN int XMLCALL xmlGetUTF8Char(const unsigned char *utf, int *len)
Definition: xmlstring.c:713
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ xmlCleanupCharEncodingHandlers()

XMLPUBFUN void XMLCALL xmlCleanupCharEncodingHandlers ( void  )

xmlCleanupCharEncodingHandlers:

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

Definition at line 1465 of file encoding.c.

1465  {
1467 
1468  if (handlers == NULL) return;
1469 
1470  for (;nbCharEncodingHandler > 0;) {
1476  }
1477  }
1478  xmlFree(handlers);
1479  handlers = NULL;
1482 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1307
static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler
Definition: encoding.c:1315
void xmlCleanupEncodingAliases(void)
Definition: encoding.c:1002
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int nbCharEncodingHandler
Definition: encoding.c:1308
#define NULL
Definition: types.h:112
Definition: name.c:38

Referenced by xmlCleanupParser().

◆ xmlCleanupEncodingAliases()

XMLPUBFUN void XMLCALL xmlCleanupEncodingAliases ( void  )

xmlCleanupEncodingAliases:

Unregisters all aliases

Definition at line 1002 of file encoding.c.

1002  {
1003  int i;
1004 
1006  return;
1007 
1008  for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
1010  xmlFree((char *) xmlCharEncodingAliases[i].name);
1013  }
1018 }
static xmlCharEncodingAliasPtr xmlCharEncodingAliases
Definition: encoding.c:61
static int xmlCharEncodingAliasesMax
Definition: encoding.c:63
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int xmlCharEncodingAliasesNb
Definition: encoding.c:62
const WCHAR * alias
Definition: main.c:67
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
#define NULL
Definition: types.h:112
Definition: name.c:38

Referenced by xmlCleanupCharEncodingHandlers().

◆ xmlDelEncodingAlias()

XMLPUBFUN int XMLCALL 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 1124 of file encoding.c.

1124  {
1125  int i;
1126 
1127  if (alias == NULL)
1128  return(-1);
1129 
1131  return(-1);
1132  /*
1133  * Walk down the list looking for a definition of the alias
1134  */
1135  for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
1137  xmlFree((char *) xmlCharEncodingAliases[i].name);
1142  return(0);
1143  }
1144  }
1145  return(-1);
1146 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static xmlCharEncodingAliasPtr xmlCharEncodingAliases
Definition: encoding.c:61
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int xmlCharEncodingAliasesNb
Definition: encoding.c:62
const WCHAR * alias
Definition: main.c:67
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
#define NULL
Definition: types.h:112
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

◆ xmlDetectCharEncoding()

XMLPUBFUN xmlCharEncoding XMLCALL 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 942 of file encoding.c.

943 {
944  if (in == NULL)
945  return(XML_CHAR_ENCODING_NONE);
946  if (len >= 4) {
947  if ((in[0] == 0x00) && (in[1] == 0x00) &&
948  (in[2] == 0x00) && (in[3] == 0x3C))
949  return(XML_CHAR_ENCODING_UCS4BE);
950  if ((in[0] == 0x3C) && (in[1] == 0x00) &&
951  (in[2] == 0x00) && (in[3] == 0x00))
952  return(XML_CHAR_ENCODING_UCS4LE);
953  if ((in[0] == 0x00) && (in[1] == 0x00) &&
954  (in[2] == 0x3C) && (in[3] == 0x00))
956  if ((in[0] == 0x00) && (in[1] == 0x3C) &&
957  (in[2] == 0x00) && (in[3] == 0x00))
959  if ((in[0] == 0x4C) && (in[1] == 0x6F) &&
960  (in[2] == 0xA7) && (in[3] == 0x94))
961  return(XML_CHAR_ENCODING_EBCDIC);
962  if ((in[0] == 0x3C) && (in[1] == 0x3F) &&
963  (in[2] == 0x78) && (in[3] == 0x6D))
964  return(XML_CHAR_ENCODING_UTF8);
965  /*
966  * Although not part of the recommendation, we also
967  * attempt an "auto-recognition" of UTF-16LE and
968  * UTF-16BE encodings.
969  */
970  if ((in[0] == 0x3C) && (in[1] == 0x00) &&
971  (in[2] == 0x3F) && (in[3] == 0x00))
973  if ((in[0] == 0x00) && (in[1] == 0x3C) &&
974  (in[2] == 0x00) && (in[3] == 0x3F))
976  }
977  if (len >= 3) {
978  /*
979  * Errata on XML-1.0 June 20 2001
980  * We now allow an UTF8 encoded BOM
981  */
982  if ((in[0] == 0xEF) && (in[1] == 0xBB) &&
983  (in[2] == 0xBF))
984  return(XML_CHAR_ENCODING_UTF8);
985  }
986  /* For UTF-16 we can recognize by the BOM */
987  if (len >= 2) {
988  if ((in[0] == 0xFE) && (in[1] == 0xFF))
990  if ((in[0] == 0xFF) && (in[1] == 0xFE))
992  }
993  return(XML_CHAR_ENCODING_NONE);
994 }
GLenum GLsizei len
Definition: glext.h:6722
GLuint in
Definition: glext.h:9616
#define NULL
Definition: types.h:112

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

◆ xmlFindCharEncodingHandler()

XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler ( const char name)

Definition at line 1660 of file encoding.c.

1660  {
1661  const char *nalias;
1662  const char *norig;
1664 #ifdef LIBXML_ICONV_ENABLED
1666  iconv_t icv_in, icv_out;
1667 #endif /* LIBXML_ICONV_ENABLED */
1668 #ifdef LIBXML_ICU_ENABLED
1670  uconv_t *ucv_in, *ucv_out;
1671 #endif /* LIBXML_ICU_ENABLED */
1672  char upper[100];
1673  int i;
1674 
1676  if (name == NULL) return(xmlDefaultCharEncodingHandler);
1677  if (name[0] == 0) return(xmlDefaultCharEncodingHandler);
1678 
1679  /*
1680  * Do the alias resolution
1681  */
1682  norig = name;
1683  nalias = xmlGetEncodingAlias(name);
1684  if (nalias != NULL)
1685  name = nalias;
1686 
1687  /*
1688  * Check first for directly registered encoding names
1689  */
1690  for (i = 0;i < 99;i++) {
1691  upper[i] = toupper(name[i]);
1692  if (upper[i] == 0) break;
1693  }
1694  upper[i] = 0;
1695 
1696  if (handlers != NULL) {
1697  for (i = 0;i < nbCharEncodingHandler; i++) {
1698  if (!strcmp(upper, handlers[i]->name)) {
1699 #ifdef DEBUG_ENCODING
1701  "Found registered handler for encoding %s\n", name);
1702 #endif
1703  return(handlers[i]);
1704  }
1705  }
1706  }
1707 
1708 #ifdef LIBXML_ICONV_ENABLED
1709  /* check whether iconv can handle this */
1710  icv_in = iconv_open("UTF-8", name);
1711  icv_out = iconv_open(name, "UTF-8");
1712  if (icv_in == (iconv_t) -1) {
1713  icv_in = iconv_open("UTF-8", upper);
1714  }
1715  if (icv_out == (iconv_t) -1) {
1716  icv_out = iconv_open(upper, "UTF-8");
1717  }
1718  if ((icv_in != (iconv_t) -1) && (icv_out != (iconv_t) -1)) {
1721  if (enc == NULL) {
1722  iconv_close(icv_in);
1723  iconv_close(icv_out);
1724  return(NULL);
1725  }
1726  memset(enc, 0, sizeof(xmlCharEncodingHandler));
1727  enc->name = xmlMemStrdup(name);
1728  enc->input = NULL;
1729  enc->output = NULL;
1730  enc->iconv_in = icv_in;
1731  enc->iconv_out = icv_out;
1732 #ifdef DEBUG_ENCODING
1734  "Found iconv handler for encoding %s\n", name);
1735 #endif
1736  return enc;
1737  } else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
1738  xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
1739  "iconv : problems with filters for '%s'\n", name);
1740  }
1741 #endif /* LIBXML_ICONV_ENABLED */
1742 #ifdef LIBXML_ICU_ENABLED
1743  /* check whether icu can handle this */
1744  ucv_in = openIcuConverter(name, 1);
1745  ucv_out = openIcuConverter(name, 0);
1746  if (ucv_in != NULL && ucv_out != NULL) {
1747  encu = (xmlCharEncodingHandlerPtr)
1749  if (encu == NULL) {
1750  closeIcuConverter(ucv_in);
1751  closeIcuConverter(ucv_out);
1752  return(NULL);
1753  }
1754  memset(encu, 0, sizeof(xmlCharEncodingHandler));
1755  encu->name = xmlMemStrdup(name);
1756  encu->input = NULL;
1757  encu->output = NULL;
1758  encu->uconv_in = ucv_in;
1759  encu->uconv_out = ucv_out;
1760 #ifdef DEBUG_ENCODING
1762  "Found ICU converter handler for encoding %s\n", name);
1763 #endif
1764  return encu;
1765  } else if (ucv_in != NULL || ucv_out != NULL) {
1766  closeIcuConverter(ucv_in);
1767  closeIcuConverter(ucv_out);
1768  xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
1769  "ICU converter : problems with filters for '%s'\n", name);
1770  }
1771 #endif /* LIBXML_ICU_ENABLED */
1772 
1773 #ifdef DEBUG_ENCODING
1775  "No handler found for encoding %s\n", name);
1776 #endif
1777 
1778  /*
1779  * Fallback using the canonical names
1780  */
1781  alias = xmlParseCharEncoding(norig);
1782  if (alias != XML_CHAR_ENCODING_ERROR) {
1783  const char* canon;
1784  canon = xmlGetCharEncodingName(alias);
1785  if ((canon != NULL) && (strcmp(name, canon))) {
1786  return(xmlFindCharEncodingHandler(canon));
1787  }
1788  }
1789 
1790  /* If "none of the above", give up */
1791  return(NULL);
1792 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1307
void xmlInitCharEncodingHandlers(void)
Definition: encoding.c:1407
xmlCharEncoding
Definition: encoding.h:58
static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler
Definition: encoding.c:1315
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1660
xmlCharEncodingOutputFunc output
Definition: encoding.h:149
xmlCharEncodingInputFunc input
Definition: encoding.h:148
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
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:1029
const WCHAR * alias
Definition: main.c:67
static int nbCharEncodingHandler
Definition: encoding.c:1308
XMLPUBVAR xmlStrdupFunc xmlMemStrdup
Definition: globals.h:251
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
xmlCharEncodingHandler * xmlCharEncodingHandlerPtr
Definition: encoding.h:145
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
xmlCharEncoding xmlParseCharEncoding(const char *name)
Definition: encoding.c:1160
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:1244
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()

XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL 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 1526 of file encoding.c.

1526  {
1528 
1530  switch (enc) {
1532  return(NULL);
1534  return(NULL);
1536  return(NULL);
1538  return(xmlUTF16LEHandler);
1540  return(xmlUTF16BEHandler);
1542  handler = xmlFindCharEncodingHandler("EBCDIC");
1543  if (handler != NULL) return(handler);
1544  handler = xmlFindCharEncodingHandler("ebcdic");
1545  if (handler != NULL) return(handler);
1546  handler = xmlFindCharEncodingHandler("EBCDIC-US");
1547  if (handler != NULL) return(handler);
1548  handler = xmlFindCharEncodingHandler("IBM-037");
1549  if (handler != NULL) return(handler);
1550  break;
1552  handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
1553  if (handler != NULL) return(handler);
1555  if (handler != NULL) return(handler);
1557  if (handler != NULL) return(handler);
1558  break;
1560  handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
1561  if (handler != NULL) return(handler);
1563  if (handler != NULL) return(handler);
1565  if (handler != NULL) return(handler);
1566  break;
1568  break;
1570  break;
1572  handler = xmlFindCharEncodingHandler("ISO-10646-UCS-2");
1573  if (handler != NULL) return(handler);
1575  if (handler != NULL) return(handler);
1577  if (handler != NULL) return(handler);
1578  break;
1579 
1580  /*
1581  * We used to keep ISO Latin encodings native in the
1582  * generated data. This led to so many problems that
1583  * this has been removed. One can still change this
1584  * back by registering no-ops encoders for those
1585  */
1587  handler = xmlFindCharEncodingHandler("ISO-8859-1");
1588  if (handler != NULL) return(handler);
1589  break;
1591  handler = xmlFindCharEncodingHandler("ISO-8859-2");
1592  if (handler != NULL) return(handler);
1593  break;
1595  handler = xmlFindCharEncodingHandler("ISO-8859-3");
1596  if (handler != NULL) return(handler);
1597  break;
1599  handler = xmlFindCharEncodingHandler("ISO-8859-4");
1600  if (handler != NULL) return(handler);
1601  break;
1603  handler = xmlFindCharEncodingHandler("ISO-8859-5");
1604  if (handler != NULL) return(handler);
1605  break;
1607  handler = xmlFindCharEncodingHandler("ISO-8859-6");
1608  if (handler != NULL) return(handler);
1609  break;
1611  handler = xmlFindCharEncodingHandler("ISO-8859-7");
1612  if (handler != NULL) return(handler);
1613  break;
1615  handler = xmlFindCharEncodingHandler("ISO-8859-8");
1616  if (handler != NULL) return(handler);
1617  break;
1619  handler = xmlFindCharEncodingHandler("ISO-8859-9");
1620  if (handler != NULL) return(handler);
1621  break;
1622 
1623 
1625  handler = xmlFindCharEncodingHandler("ISO-2022-JP");
1626  if (handler != NULL) return(handler);
1627  break;
1629  handler = xmlFindCharEncodingHandler("SHIFT-JIS");
1630  if (handler != NULL) return(handler);
1631  handler = xmlFindCharEncodingHandler("SHIFT_JIS");
1632  if (handler != NULL) return(handler);
1633  handler = xmlFindCharEncodingHandler("Shift_JIS");
1634  if (handler != NULL) return(handler);
1635  break;
1637  handler = xmlFindCharEncodingHandler("EUC-JP");
1638  if (handler != NULL) return(handler);
1639  break;
1640  default:
1641  break;
1642  }
1643 
1644 #ifdef DEBUG_ENCODING
1646  "No handler found for encoding %d\n", enc);
1647 #endif
1648  return(NULL);
1649 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1307
void xmlInitCharEncodingHandlers(void)
Definition: encoding.c:1407
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler
Definition: encoding.c:52
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1660
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler
Definition: encoding.c:51
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
#define NULL
Definition: types.h:112
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlSwitchEncoding().

◆ xmlGetCharEncodingName()

XMLPUBFUN const char* XMLCALL 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 1244 of file encoding.c.

1244  {
1245  switch (enc) {
1247  return(NULL);
1249  return(NULL);
1251  return("UTF-8");
1253  return("UTF-16");
1255  return("UTF-16");
1257  return("EBCDIC");
1259  return("ISO-10646-UCS-4");
1261  return("ISO-10646-UCS-4");
1263  return("ISO-10646-UCS-4");
1265  return("ISO-10646-UCS-4");
1267  return("ISO-10646-UCS-2");
1269  return("ISO-8859-1");
1271  return("ISO-8859-2");
1273  return("ISO-8859-3");
1275  return("ISO-8859-4");
1277  return("ISO-8859-5");
1279  return("ISO-8859-6");
1281  return("ISO-8859-7");
1283  return("ISO-8859-8");
1285  return("ISO-8859-9");
1287  return("ISO-2022-JP");
1289  return("Shift-JIS");
1291  return("EUC-JP");
1293  return(NULL);
1294  }
1295  return(NULL);
1296 }
#define NULL
Definition: types.h:112

Referenced by xmlFindCharEncodingHandler(), and xsltSaveResultTo().

◆ xmlGetEncodingAlias()

XMLPUBFUN const char* XMLCALL 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 1029 of file encoding.c.

1029  {
1030  int i;
1031  char upper[100];
1032 
1033  if (alias == NULL)
1034  return(NULL);
1035 
1037  return(NULL);
1038 
1039  for (i = 0;i < 99;i++) {
1040  upper[i] = toupper(alias[i]);
1041  if (upper[i] == 0) break;
1042  }
1043  upper[i] = 0;
1044 
1045  /*
1046  * Walk down the list looking for a definition of the alias
1047  */
1048  for (i = 0;i < xmlCharEncodingAliasesNb;i++) {
1049  if (!strcmp(xmlCharEncodingAliases[i].alias, upper)) {
1050  return(xmlCharEncodingAliases[i].name);
1051  }
1052  }
1053  return(NULL);
1054 }
static xmlCharEncodingAliasPtr xmlCharEncodingAliases
Definition: encoding.c:61
int toupper(int c)
Definition: utclib.c:881
static int xmlCharEncodingAliasesNb
Definition: encoding.c:62
const WCHAR * alias
Definition: main.c:67
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
#define NULL
Definition: types.h:112
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

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

◆ xmlInitCharEncodingHandlers()

XMLPUBFUN void XMLCALL 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 1407 of file encoding.c.

1407  {
1408  unsigned short int tst = 0x1234;
1409  unsigned char *ptr = (unsigned char *) &tst;
1410 
1411  if (handlers != NULL) return;
1412 
1415 
1416  if (*ptr == 0x12) xmlLittleEndian = 0;
1417  else if (*ptr == 0x34) xmlLittleEndian = 1;
1418  else {
1419  xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
1420  "Odd problem at endianness detection\n", NULL);
1421  }
1422 
1423  if (handlers == NULL) {
1424  xmlEncodingErrMemory("xmlInitCharEncodingHandlers : out of memory !\n");
1425  return;
1426  }
1428 #ifdef LIBXML_OUTPUT_ENABLED
1430  xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE);
1432  xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, UTF8ToUTF16BE);
1433  xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, UTF8ToUTF16);
1434  xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1);
1435  xmlNewCharEncodingHandler("ASCII", asciiToUTF8, UTF8Toascii);
1436  xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, UTF8Toascii);
1437 #ifdef LIBXML_HTML_ENABLED
1438  xmlNewCharEncodingHandler("HTML", NULL, UTF8ToHtml);
1439 #endif
1440 #else
1449 #endif /* LIBXML_OUTPUT_ENABLED */
1450 #if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
1451 #ifdef LIBXML_ISO8859X_ENABLED
1452  xmlRegisterCharEncodingHandlersISO8859x ();
1453 #endif
1454 #endif
1455 
1456 }
static void xmlEncodingErrMemory(const char *extra)
Definition: encoding.c:84
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1307
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:742
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler
Definition: encoding.c:51
static int UTF16LEToUTF8(unsigned char *out, int *outlen, const unsigned char *inb, int *inlenb)
Definition: encoding.c:499
static PVOID ptr
Definition: dispmode.c:27
#define MAX_ENCODING_HANDLERS
Definition: encoding.c:1306
static int xmlLittleEndian
Definition: encoding.c:75
xmlCharEncodingHandlerPtr xmlNewCharEncodingHandler(const char *name, xmlCharEncodingInputFunc input, xmlCharEncodingOutputFunc output)
Definition: encoding.c:1328
#define NULL
Definition: types.h:112
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()

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

Definition at line 1328 of file encoding.c.

1330  {
1332  const char *alias;
1333  char upper[500];
1334  int i;
1335  char *up = NULL;
1336 
1337  /*
1338  * Do the alias resolution
1339  */
1341  if (alias != NULL)
1342  name = alias;
1343 
1344  /*
1345  * Keep only the uppercase version of the encoding.
1346  */
1347  if (name == NULL) {
1348  xmlEncodingErr(XML_I18N_NO_NAME,
1349  "xmlNewCharEncodingHandler : no name !\n", NULL);
1350  return(NULL);
1351  }
1352  for (i = 0;i < 499;i++) {
1353  upper[i] = toupper(name[i]);
1354  if (upper[i] == 0) break;
1355  }
1356  upper[i] = 0;
1357  up = xmlMemStrdup(upper);
1358  if (up == NULL) {
1359  xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
1360  return(NULL);
1361  }
1362 
1363  /*
1364  * allocate and fill-up an handler block.
1365  */
1368  if (handler == NULL) {
1369  xmlFree(up);
1370  xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
1371  return(NULL);
1372  }
1373  memset(handler, 0, sizeof(xmlCharEncodingHandler));
1374  handler->input = input;
1375  handler->output = output;
1376  handler->name = up;
1377 
1378 #ifdef LIBXML_ICONV_ENABLED
1379  handler->iconv_in = NULL;
1380  handler->iconv_out = NULL;
1381 #endif
1382 #ifdef LIBXML_ICU_ENABLED
1383  handler->uconv_in = NULL;
1384  handler->uconv_out = NULL;
1385 #endif
1386 
1387  /*
1388  * registers and returns the handler.
1389  */
1391 #ifdef DEBUG_ENCODING
1393  "Registered encoding handler for %s\n", name);
1394 #endif
1395  return(handler);
1396 }
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
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
int toupper(int c)
Definition: utclib.c:881
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
const char * xmlGetEncodingAlias(const char *alias)
Definition: encoding.c:1029
const WCHAR * alias
Definition: main.c:67
void xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler)
Definition: encoding.c:1491
XMLPUBVAR xmlStrdupFunc xmlMemStrdup
Definition: globals.h:251
GLenum GLenum GLenum input
Definition: glext.h:9031
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
xmlCharEncodingHandler * xmlCharEncodingHandlerPtr
Definition: encoding.h:145
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
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()

XMLPUBFUN xmlCharEncoding XMLCALL xmlParseCharEncoding ( const char name)

Definition at line 1160 of file encoding.c.

1161 {
1162  const char *alias;
1163  char upper[500];
1164  int i;
1165 
1166  if (name == NULL)
1167  return(XML_CHAR_ENCODING_NONE);
1168 
1169  /*
1170  * Do the alias resolution
1171  */
1173  if (alias != NULL)
1174  name = alias;
1175 
1176  for (i = 0;i < 499;i++) {
1177  upper[i] = toupper(name[i]);
1178  if (upper[i] == 0) break;
1179  }
1180  upper[i] = 0;
1181 
1182  if (!strcmp(upper, "")) return(XML_CHAR_ENCODING_NONE);
1183  if (!strcmp(upper, "UTF-8")) return(XML_CHAR_ENCODING_UTF8);
1184  if (!strcmp(upper, "UTF8")) return(XML_CHAR_ENCODING_UTF8);
1185 
1186  /*
1187  * NOTE: if we were able to parse this, the endianness of UTF16 is
1188  * already found and in use
1189  */
1190  if (!strcmp(upper, "UTF-16")) return(XML_CHAR_ENCODING_UTF16LE);
1191  if (!strcmp(upper, "UTF16")) return(XML_CHAR_ENCODING_UTF16LE);
1192 
1193  if (!strcmp(upper, "ISO-10646-UCS-2")) return(XML_CHAR_ENCODING_UCS2);
1194  if (!strcmp(upper, "UCS-2")) return(XML_CHAR_ENCODING_UCS2);
1195  if (!strcmp(upper, "UCS2")) return(XML_CHAR_ENCODING_UCS2);
1196 
1197  /*
1198  * NOTE: if we were able to parse this, the endianness of UCS4 is
1199  * already found and in use
1200  */
1201  if (!strcmp(upper, "ISO-10646-UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
1202  if (!strcmp(upper, "UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
1203  if (!strcmp(upper, "UCS4")) return(XML_CHAR_ENCODING_UCS4LE);
1204 
1205 
1206  if (!strcmp(upper, "ISO-8859-1")) return(XML_CHAR_ENCODING_8859_1);
1207  if (!strcmp(upper, "ISO-LATIN-1")) return(XML_CHAR_ENCODING_8859_1);
1208  if (!strcmp(upper, "ISO LATIN 1")) return(XML_CHAR_ENCODING_8859_1);
1209 
1210  if (!strcmp(upper, "ISO-8859-2")) return(XML_CHAR_ENCODING_8859_2);
1211  if (!strcmp(upper, "ISO-LATIN-2")) return(XML_CHAR_ENCODING_8859_2);
1212  if (!strcmp(upper, "ISO LATIN 2")) return(XML_CHAR_ENCODING_8859_2);
1213 
1214  if (!strcmp(upper, "ISO-8859-3")) return(XML_CHAR_ENCODING_8859_3);
1215  if (!strcmp(upper, "ISO-8859-4")) return(XML_CHAR_ENCODING_8859_4);
1216  if (!strcmp(upper, "ISO-8859-5")) return(XML_CHAR_ENCODING_8859_5);
1217  if (!strcmp(upper, "ISO-8859-6")) return(XML_CHAR_ENCODING_8859_6);
1218  if (!strcmp(upper, "ISO-8859-7")) return(XML_CHAR_ENCODING_8859_7);
1219  if (!strcmp(upper, "ISO-8859-8")) return(XML_CHAR_ENCODING_8859_8);
1220  if (!strcmp(upper, "ISO-8859-9")) return(XML_CHAR_ENCODING_8859_9);
1221 
1222  if (!strcmp(upper, "ISO-2022-JP")) return(XML_CHAR_ENCODING_2022_JP);
1223  if (!strcmp(upper, "SHIFT_JIS")) return(XML_CHAR_ENCODING_SHIFT_JIS);
1224  if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
1225 
1226 #ifdef DEBUG_ENCODING
1227  xmlGenericError(xmlGenericErrorContext, "Unknown encoding %s\n", name);
1228 #endif
1229  return(XML_CHAR_ENCODING_ERROR);
1230 }
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
int toupper(int c)
Definition: utclib.c:881
const char * xmlGetEncodingAlias(const char *alias)
Definition: encoding.c:1029
const WCHAR * alias
Definition: main.c:67
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
#define NULL
Definition: types.h:112
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlFindCharEncodingHandler().

◆ xmlRegisterCharEncodingHandler()

XMLPUBFUN void XMLCALL xmlRegisterCharEncodingHandler ( xmlCharEncodingHandlerPtr  handler)

xmlRegisterCharEncodingHandler: @handler: the xmlCharEncodingHandlerPtr handler block

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

Definition at line 1491 of file encoding.c.

1491  {
1493  if ((handler == NULL) || (handlers == NULL)) {
1494  xmlEncodingErr(XML_I18N_NO_HANDLER,
1495  "xmlRegisterCharEncodingHandler: NULL handler !\n", NULL);
1496  goto free_handler;
1497  }
1498 
1500  xmlEncodingErr(XML_I18N_EXCESS_HANDLER,
1501  "xmlRegisterCharEncodingHandler: Too many handler registered, see %s\n",
1502  "MAX_ENCODING_HANDLERS");
1503  goto free_handler;
1504  }
1506  return;
1507 
1508 free_handler:
1509  if (handler != NULL) {
1510  if (handler->name != NULL) {
1511  xmlFree(handler->name);
1512  }
1513  xmlFree(handler);
1514  }
1515 }
static xmlCharEncodingHandlerPtr * handlers
Definition: encoding.c:1307
void xmlInitCharEncodingHandlers(void)
Definition: encoding.c:1407
#define MAX_ENCODING_HANDLERS
Definition: encoding.c:1306
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
static int nbCharEncodingHandler
Definition: encoding.c:1308
#define NULL
Definition: types.h:112
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

Referenced by xmlNewCharEncodingHandler().