libxml2_encoding.h File Reference

Enum xmlCharEncoding

Typedef xmlCharEncodingInputFunc

typedef int(*xmlCharEncodingInputFunc

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

Typedef xmlCharEncodingOutputFunc

typedef int(*xmlCharEncodingOutputFunc

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

Typedef xmlCharEncodingHandler

typedef struct _xmlCharEncodingHandlerxmlCharEncodingHandler

Typedef xmlCharEncodingHandlerPtr

typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr

xmlInitCharEncodingHandlers ( void )

XMLPUBFUN void XMLCALLxmlInitCharEncodingHandlers(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.

OOM: possible --> OOM flag is set

xmlCleanupCharEncodingHandlers ( void )

XMLPUBFUN void XMLCALLxmlCleanupCharEncodingHandlers(void)

xmlCleanupCharEncodingHandlers:

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

OOM: never

xmlRegisterCharEncodingHandler ( xmlCharEncodingHandlerPtr )

XMLPUBFUN void XMLCALLxmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtrhandler)

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

OOM: never

Parameters
handlerthe xmlCharEncodingHandlerPtr handler block

xmlGetCharEncodingHandler ( xmlCharEncoding )

XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALLxmlGetCharEncodingHandler(xmlCharEncodingenc)

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

Returns the handler, NULL if not found

OOM: possible --> OOM flag is set

Parameters
encan xmlCharEncoding value.

xmlFindCharEncodingHandler ( const char * )

XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALLxmlFindCharEncodingHandler(const char *name)

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

Returns the handler or NULL if not found

OOM: possible --> OOM flag is set

Parameters
namea string describing the char encoding.

xmlNewCharEncodingHandler ( const char *, xmlCharEncodingInputFunc, xmlCharEncodingOutputFunc )

XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALLxmlNewCharEncodingHandler(const char *name,
xmlCharEncodingInputFuncinput,
xmlCharEncodingOutputFuncoutput
)

xmlNewCharEncodingHandler: Create and registers an xmlCharEncodingHandler.

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

OOM: possible --> OOM flag is set

Parameters
namethe encoding name, in UTF-8 format (ASCII actually)
inputthe xmlCharEncodingInputFunc to read that encoding
outputthe xmlCharEncodingOutputFunc to write that encoding

xmlAddEncodingAlias ( const char *, const char * )

XMLPUBFUN int XMLCALLxmlAddEncodingAlias(const char *name,
const char *alias
)

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

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

Parameters
namethe encoding name as parsed, in UTF-8 format (ASCII actually)
aliasthe alias name as parsed, in UTF-8 format (ASCII actually)

xmlDelEncodingAlias ( const char * )

XMLPUBFUN int XMLCALLxmlDelEncodingAlias(const char *alias)

xmlDelEncodingAlias: Unregisters an encoding alias alias

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

Parameters
aliasthe alias name as parsed, in UTF-8 format (ASCII actually)

xmlGetEncodingAlias ( const char * )

XMLPUBFUN const char *XMLCALLxmlGetEncodingAlias(const char *alias)

xmlGetEncodingAlias: Lookup an encoding name for the given alias.

Returns NULL if not found, otherwise the original name

OOM: never

Parameters
aliasthe alias name as parsed, in UTF-8 format (ASCII actually)

xmlCleanupEncodingAliases ( void )

XMLPUBFUN void XMLCALLxmlCleanupEncodingAliases(void)

xmlCleanupEncodingAliases:

Unregisters all aliases

xmlParseCharEncoding ( const char * )

XMLPUBFUN xmlCharEncoding XMLCALLxmlParseCharEncoding(const char *name)

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.

OOM: never

Parameters
namethe encoding name as parsed, in UTF-8 format (ASCII actually)

xmlGetCharEncodingName ( xmlCharEncoding )

XMLPUBFUN const char *XMLCALLxmlGetCharEncodingName(xmlCharEncodingenc)

xmlGetCharEncodingName: 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

Parameters
encthe encoding

xmlDetectCharEncoding ( const unsigned char *, int )

XMLPUBFUN xmlCharEncoding XMLCALLxmlDetectCharEncoding(const unsigned char *in,
intlen
)

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

OOM: never

Parameters
ina pointer to the first bytes of the XML entity, must be at least 2 bytes long (at least 4 if encoding is UTF4 variant).
lenpointer to the length of the buffer

xmlCharEncOutFunc ( xmlCharEncodingHandler *, xmlBufferPtr, xmlBufferPtr )

XMLPUBFUN int XMLCALLxmlCharEncOutFunc(xmlCharEncodingHandler *handler,
xmlBufferPtrout,
xmlBufferPtrin
)

xmlCharEncOutFunc: 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

OOM: unknown status / function pointers are in use possible, but reporting is not guaranteed

Parameters
handlerchar enconding transformation data structure
outan xmlBuffer for the output.
inan xmlBuffer for the input

xmlCharEncInFunc ( xmlCharEncodingHandler *, xmlBufferPtr, xmlBufferPtr )

XMLPUBFUN int XMLCALLxmlCharEncInFunc(xmlCharEncodingHandler *handler,
xmlBufferPtrout,
xmlBufferPtrin
)

xmlCharEncInFunc: 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

ISSUE: OOM: possible

Parameters
handlerchar encoding transformation data structure
outan xmlBuffer for the output.
inan xmlBuffer for the input

xmlCharEncFirstLine ( xmlCharEncodingHandler *, xmlBufferPtr, xmlBufferPtr )

XMLPUBFUN int XMLCALLxmlCharEncFirstLine(xmlCharEncodingHandler *handler,
xmlBufferPtrout,
xmlBufferPtrin
)

xmlCharEncFirstLine: 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

OOM: possible --> check OOM flag

Parameters
handlerchar enconding transformation data structure
outan xmlBuffer for the output.
inan xmlBuffer for the input

xmlCharEncCloseFunc ( xmlCharEncodingHandler * )

XMLPUBFUN int XMLCALLxmlCharEncCloseFunc(xmlCharEncodingHandler *handler)

xmlCharEncCloseFunc: Generic front-end for encoding handler close function

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

OOM: never / not clear (depends on ICONV support)

Parameters
handlerchar enconding transformation data structure

UTF8Toisolat1 ( unsigned char *, int *, const unsigned char *, int * )

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

isolat1ToUTF8 ( unsigned char *, int *, const unsigned char *, int * )

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

isolat1ToUTF8: Take a block of ISO Latin 1 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.

Parameters
outa pointer to an array of bytes to store the result
outlenthe length of out
ina pointer to an array of ISO Latin 1 chars
inlenthe length of in