Back to Turicreate

Module encoding from libxml2

deps/src/libxml2-2.9.1/doc/html/libxml-encoding.html

6.4.118.2 KB
Original Source

| |

|

|

|

Module encoding from libxml2

|

|

|

|

|

|

| API Menu | |

|

| API Indexes | |

|

| Related links | |

|

|

|

|

|

|

| | dict | | API documentation | | The XML C parser and toolkit of Gnome | entities | |

interface for the encoding conversion functions needed for XML basic encoding and iconv() support. Related specs are rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies [ISO-10646] UTF-8 and UTF-16 in Annexes [ISO-8859-1] ISO Latin-1 characters codes. [UNICODE] The Unicode Consortium, "The Unicode Standard -- Worldwide Character Encoding -- Version 1.0", Addison- Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is described in Unicode Technical Report #4. [US-ASCII] Coded Character Set--7-bit American Standard Code for Information Interchange, ANSI X3.4-1986.

Table of Contents

Structure[uconv\_t](#uconv_t)
struct _uconv_t
Enum[xmlCharEncoding](#xmlCharEncoding)
Structure[xmlCharEncodingHandler](#xmlCharEncodingHandler)
struct _xmlCharEncodingHandler
Typedef[xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)*xmlCharEncodingHandlerPtr
int[UTF8Toisolat1](#UTF8Toisolat1)(unsigned char * out,
int * outlen,
const unsigned char * in,
int * inlen)
int[isolat1ToUTF8](#isolat1ToUTF8)(unsigned char * out,
int * outlen,
const unsigned char * in,
int * inlen)
int[xmlAddEncodingAlias](#xmlAddEncodingAlias)(const char * name,
const char * alias)
int[xmlCharEncCloseFunc](#xmlCharEncCloseFunc)([xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)* handler)
int[xmlCharEncFirstLine](#xmlCharEncFirstLine)([xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)* handler,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)out,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)in)
int[xmlCharEncInFunc](#xmlCharEncInFunc)([xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)* handler,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)out,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)in)
int[xmlCharEncOutFunc](#xmlCharEncOutFunc)([xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)* handler,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)out,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)in)
Function type:[xmlCharEncodingInputFunc](#xmlCharEncodingInputFunc)int[xmlCharEncodingInputFunc](#xmlCharEncodingInputFunc)(unsigned char * out,
int * outlen,
const unsigned char * in,
int * inlen)
Function type:[xmlCharEncodingOutputFunc](#xmlCharEncodingOutputFunc)int[xmlCharEncodingOutputFunc](#xmlCharEncodingOutputFunc)(unsigned char * out,
int * outlen,
const unsigned char * in,
int * inlen)
void[xmlCleanupCharEncodingHandlers](#xmlCleanupCharEncodingHandlers)(void)
void[xmlCleanupEncodingAliases](#xmlCleanupEncodingAliases)(void)
int[xmlDelEncodingAlias](#xmlDelEncodingAlias)(const char * alias)
[xmlCharEncoding](libxml-encoding.html#xmlCharEncoding)[xmlDetectCharEncoding](#xmlDetectCharEncoding)(const unsigned char * in,
int len)
[xmlCharEncodingHandlerPtr](libxml-encoding.html#xmlCharEncodingHandlerPtr)[xmlFindCharEncodingHandler](#xmlFindCharEncodingHandler)(const char * name)
[xmlCharEncodingHandlerPtr](libxml-encoding.html#xmlCharEncodingHandlerPtr)[xmlGetCharEncodingHandler](#xmlGetCharEncodingHandler)([xmlCharEncoding](libxml-encoding.html#xmlCharEncoding)enc)
const char *[xmlGetCharEncodingName](#xmlGetCharEncodingName)([xmlCharEncoding](libxml-encoding.html#xmlCharEncoding)enc)
const char *[xmlGetEncodingAlias](#xmlGetEncodingAlias)(const char * alias)
void[xmlInitCharEncodingHandlers](#xmlInitCharEncodingHandlers)(void)
[xmlCharEncodingHandlerPtr](libxml-encoding.html#xmlCharEncodingHandlerPtr)[xmlNewCharEncodingHandler](#xmlNewCharEncodingHandler)(const char * name,
[xmlCharEncodingInputFunc](libxml-encoding.html#xmlCharEncodingInputFunc)input,
[xmlCharEncodingOutputFunc](libxml-encoding.html#xmlCharEncodingOutputFunc)output)
[xmlCharEncoding](libxml-encoding.html#xmlCharEncoding)[xmlParseCharEncoding](#xmlParseCharEncoding)(const char * name)
void[xmlRegisterCharEncodingHandler](#xmlRegisterCharEncodingHandler)([xmlCharEncodingHandlerPtr](libxml-encoding.html#xmlCharEncodingHandlerPtr)handler)

Description

Structure uconv_t

Structure uconv_t
struct _uconv_t {
    UConverter *	uconv	: for conversion between an encoding and
    UConverter *	utf8	: for conversion between UTF-8 and UTF-16
}

Enum xmlCharEncoding

Enum xmlCharEncoding {XML\_CHAR\_ENCODING\_ERROR= -1 : No char encoding detectedXML\_CHAR\_ENCODING\_NONE= 0 : No char encoding detectedXML\_CHAR\_ENCODING\_UTF8= 1 : UTF-8XML\_CHAR\_ENCODING\_UTF16LE= 2 : UTF-16 little endianXML\_CHAR\_ENCODING\_UTF16BE= 3 : UTF-16 big endianXML\_CHAR\_ENCODING\_UCS4LE= 4 : UCS-4 little endianXML\_CHAR\_ENCODING\_UCS4BE= 5 : UCS-4 big endianXML\_CHAR\_ENCODING\_EBCDIC= 6 : EBCDIC uh!XML\_CHAR\_ENCODING\_UCS4\_2143= 7 : UCS-4 unusual orderingXML\_CHAR\_ENCODING\_UCS4\_3412= 8 : UCS-4 unusual orderingXML\_CHAR\_ENCODING\_UCS2= 9 : UCS-2XML\_CHAR\_ENCODING\_8859\_1= 10 : ISO-8859-1 ISO Latin 1XML\_CHAR\_ENCODING\_8859\_2= 11 : ISO-8859-2 ISO Latin 2XML\_CHAR\_ENCODING\_8859\_3= 12 : ISO-8859-3XML\_CHAR\_ENCODING\_8859\_4= 13 : ISO-8859-4XML\_CHAR\_ENCODING\_8859\_5= 14 : ISO-8859-5XML\_CHAR\_ENCODING\_8859\_6= 15 : ISO-8859-6XML\_CHAR\_ENCODING\_8859\_7= 16 : ISO-8859-7XML\_CHAR\_ENCODING\_8859\_8= 17 : ISO-8859-8XML\_CHAR\_ENCODING\_8859\_9= 18 : ISO-8859-9XML\_CHAR\_ENCODING\_2022\_JP= 19 : ISO-2022-JPXML\_CHAR\_ENCODING\_SHIFT\_JIS= 20 : Shift_JISXML\_CHAR\_ENCODING\_EUC\_JP= 21 : EUC-JPXML\_CHAR\_ENCODING\_ASCII= 22 : pure ASCII
}

Structure xmlCharEncodingHandler

Structure xmlCharEncodingHandler
struct _xmlCharEncodingHandler {
    char *	name[xmlCharEncodingInputFunc](libxml-encoding.html#xmlCharEncodingInputFunc)input[xmlCharEncodingOutputFunc](libxml-encoding.html#xmlCharEncodingOutputFunc)output
    iconv_t	iconv_in
    iconv_t	iconv_out[uconv\_t](libxml-encoding.html#uconv_t)*	uconv_in[uconv\_t](libxml-encoding.html#uconv_t)*	uconv_out
}

Function: UTF8Toisolat1

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

Take a block of UTF-8 chars in and try to convert it to an ISO Latin 1 block of chars out.

| 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 | | Returns: | the number of bytes written if success, -2 if the transcoding fails, 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. |

Function: isolat1ToUTF8

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

Take a block of ISO Latin 1 chars in and try to convert it to an UTF-8 block of chars out.

| 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 | | 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. |

Function: xmlAddEncodingAlias

int	xmlAddEncodingAlias (const char * name,
const char * alias)

Registers an alias @alias for an encoding named @name. Existing alias will be overwritten.

| name: | the encoding name as parsed, in UTF-8 format (ASCII actually) | | alias: | the alias name as parsed, in UTF-8 format (ASCII actually) | | Returns: | 0 in case of success, -1 in case of error |

Function: xmlCharEncCloseFunc

int	xmlCharEncCloseFunc ([xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)* handler)

Generic front-end for encoding handler close function

| handler: | char enconding transformation data structure | | Returns: | 0 if success, or -1 in case of error |

Function: xmlCharEncFirstLine

int	xmlCharEncFirstLine ([xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)* handler,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)out,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)in)

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

| handler: | char enconding transformation data structure | | out: | an xmlBuffer for the output. | | in: | an xmlBuffer for 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 |

Function: xmlCharEncInFunc

int	xmlCharEncInFunc ([xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)* handler,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)out,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)in)

Generic front-end for the encoding handler input function

| handler: | char encoding transformation data structure | | out: | an xmlBuffer for the output. | | in: | an xmlBuffer for 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 |

Function: xmlCharEncOutFunc

int	xmlCharEncOutFunc ([xmlCharEncodingHandler](libxml-encoding.html#xmlCharEncodingHandler)* handler,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)out,
[xmlBufferPtr](libxml-tree.html#xmlBufferPtr)in)

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.

| handler: | char enconding transformation data structure | | out: | an xmlBuffer for the output. | | in: | an xmlBuffer for 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 |

Function type: xmlCharEncodingInputFunc

Function type: xmlCharEncodingInputFunc
int	xmlCharEncodingInputFunc	(unsigned char * out,
int * outlen,
const unsigned char * in,
int * inlen)

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

| 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 | | 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. |

Function type: xmlCharEncodingOutputFunc

Function type: xmlCharEncodingOutputFunc
int	xmlCharEncodingOutputFunc	(unsigned char * out,
int * outlen,
const unsigned char * in,
int * inlen)

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.

| 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 | | 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. |

Function: xmlCleanupCharEncodingHandlers

void	xmlCleanupCharEncodingHandlers	(void)

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

Function: xmlCleanupEncodingAliases

void	xmlCleanupEncodingAliases	(void)

Unregisters all aliases

Function: xmlDelEncodingAlias

int	xmlDelEncodingAlias (const char * alias)

Unregisters an encoding alias @alias

| alias: | the alias name as parsed, in UTF-8 format (ASCII actually) | | Returns: | 0 in case of success, -1 in case of error |

Function: xmlDetectCharEncoding

[xmlCharEncoding](libxml-encoding.html#xmlCharEncoding)xmlDetectCharEncoding	(const unsigned char * in,
int len)

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.

| 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 | | Returns: | one of the XML_CHAR_ENCODING_... values. |

Function: xmlFindCharEncodingHandler

[xmlCharEncodingHandlerPtr](libxml-encoding.html#xmlCharEncodingHandlerPtr)xmlFindCharEncodingHandler	(const char * name)

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

| name: | a string describing the char encoding. | | Returns: | the handler or NULL if not found |

Function: xmlGetCharEncodingHandler

[xmlCharEncodingHandlerPtr](libxml-encoding.html#xmlCharEncodingHandlerPtr)xmlGetCharEncodingHandler	([xmlCharEncoding](libxml-encoding.html#xmlCharEncoding)enc)

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

| enc: | an xmlCharEncoding value. | | Returns: | the handler or NULL if not found |

Function: xmlGetCharEncodingName

const char *	xmlGetCharEncodingName	([xmlCharEncoding](libxml-encoding.html#xmlCharEncoding)enc)

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

| enc: | the encoding | | Returns: | the canonical name for the given encoding |

Function: xmlGetEncodingAlias

const char *	xmlGetEncodingAlias	(const char * alias)

Lookup an encoding name for the given alias.

| alias: | the alias name as parsed, in UTF-8 format (ASCII actually) | | Returns: | NULL if not found, otherwise the original name |

Function: xmlInitCharEncodingHandlers

void	xmlInitCharEncodingHandlers	(void)

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.

Function: xmlNewCharEncodingHandler

[xmlCharEncodingHandlerPtr](libxml-encoding.html#xmlCharEncodingHandlerPtr)xmlNewCharEncodingHandler	(const char * name,
[xmlCharEncodingInputFunc](libxml-encoding.html#xmlCharEncodingInputFunc)input,
[xmlCharEncodingOutputFunc](libxml-encoding.html#xmlCharEncodingOutputFunc)output)

Create and registers an xmlCharEncodingHandler.

| name: | the encoding name, in UTF-8 format (ASCII actually) | | input: | the xmlCharEncodingInputFunc to read that encoding | | output: | the xmlCharEncodingOutputFunc to write that encoding | | Returns: | the xmlCharEncodingHandlerPtr created (or NULL in case of error). |

Function: xmlParseCharEncoding

[xmlCharEncoding](libxml-encoding.html#xmlCharEncoding)xmlParseCharEncoding	(const char * name)

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.

| name: | the encoding name as parsed, in UTF-8 format (ASCII actually) | | Returns: | one of the XML_CHAR_ENCODING_... values or XML_CHAR_ENCODING_NONE if not recognized. |

Function: xmlRegisterCharEncodingHandler

void	xmlRegisterCharEncodingHandler	([xmlCharEncodingHandlerPtr](libxml-encoding.html#xmlCharEncodingHandlerPtr)handler)

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

| handler: | the xmlCharEncodingHandlerPtr handler block |

Daniel Veillard

|

|

|

|

|