2001-02-23 20:55:21 +03:00
/*
2003-11-18 23:56:51 +03:00
* Summary : interface for the encoding conversion functions
* Description : interface for the encoding conversion functions needed for
* XML basic encoding and iconv ( ) support .
2001-02-23 20:55:21 +03:00
*
2003-11-18 23:56:51 +03:00
* Related specs are
2001-02-23 20:55:21 +03:00
* 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.
*
2003-11-18 23:56:51 +03:00
* Copy : See Copyright for the status of this software .
2001-02-23 20:55:21 +03:00
*
2003-11-18 23:56:51 +03:00
* Author : Daniel Veillard
2001-02-23 20:55:21 +03:00
*/
# ifndef __XML_CHAR_ENCODING_H__
# define __XML_CHAR_ENCODING_H__
# include <libxml/xmlversion.h>
2002-11-08 20:18:52 +03:00
2001-02-23 20:55:21 +03:00
# ifdef __cplusplus
extern " C " {
# endif
2023-02-22 19:11:20 +03:00
typedef enum {
XML_ENC_ERR_SUCCESS = 0 ,
2024-06-28 22:19:44 +03:00
XML_ENC_ERR_INTERNAL = - 1 ,
2023-02-22 19:11:20 +03:00
XML_ENC_ERR_INPUT = - 2 ,
2024-06-28 22:19:44 +03:00
XML_ENC_ERR_SPACE = - 3 ,
XML_ENC_ERR_MEMORY = - 4
2023-02-22 19:11:20 +03:00
} xmlCharEncError ;
2003-11-16 09:25:42 +03:00
/*
2001-05-19 17:24:56 +04:00
* xmlCharEncoding :
*
2002-03-12 21:46:39 +03:00
* Predefined values for some standard encodings .
2001-02-23 20:55:21 +03:00
*/
typedef enum {
XML_CHAR_ENCODING_ERROR = - 1 , /* No char encoding detected */
XML_CHAR_ENCODING_NONE = 0 , /* No char encoding detected */
XML_CHAR_ENCODING_UTF8 = 1 , /* UTF-8 */
XML_CHAR_ENCODING_UTF16LE = 2 , /* UTF-16 little endian */
XML_CHAR_ENCODING_UTF16BE = 3 , /* UTF-16 big endian */
XML_CHAR_ENCODING_UCS4LE = 4 , /* UCS-4 little endian */
XML_CHAR_ENCODING_UCS4BE = 5 , /* UCS-4 big endian */
XML_CHAR_ENCODING_EBCDIC = 6 , /* EBCDIC uh! */
XML_CHAR_ENCODING_UCS4_2143 = 7 , /* UCS-4 unusual ordering */
XML_CHAR_ENCODING_UCS4_3412 = 8 , /* UCS-4 unusual ordering */
XML_CHAR_ENCODING_UCS2 = 9 , /* UCS-2 */
XML_CHAR_ENCODING_8859_1 = 10 , /* ISO-8859-1 ISO Latin 1 */
XML_CHAR_ENCODING_8859_2 = 11 , /* ISO-8859-2 ISO Latin 2 */
XML_CHAR_ENCODING_8859_3 = 12 , /* ISO-8859-3 */
XML_CHAR_ENCODING_8859_4 = 13 , /* ISO-8859-4 */
XML_CHAR_ENCODING_8859_5 = 14 , /* ISO-8859-5 */
XML_CHAR_ENCODING_8859_6 = 15 , /* ISO-8859-6 */
XML_CHAR_ENCODING_8859_7 = 16 , /* ISO-8859-7 */
XML_CHAR_ENCODING_8859_8 = 17 , /* ISO-8859-8 */
XML_CHAR_ENCODING_8859_9 = 18 , /* ISO-8859-9 */
XML_CHAR_ENCODING_2022_JP = 19 , /* ISO-2022-JP */
XML_CHAR_ENCODING_SHIFT_JIS = 20 , /* Shift_JIS */
XML_CHAR_ENCODING_EUC_JP = 21 , /* EUC-JP */
2024-06-27 21:39:52 +03:00
XML_CHAR_ENCODING_ASCII = 22 , /* pure ASCII */
/* Available since 2.14.0 */
XML_CHAR_ENCODING_UTF16 = 23 , /* UTF-16 native */
XML_CHAR_ENCODING_HTML = 24 , /* HTML (output only) */
XML_CHAR_ENCODING_8859_10 = 25 , /* ISO-8859-10 */
XML_CHAR_ENCODING_8859_11 = 26 , /* ISO-8859-11 */
XML_CHAR_ENCODING_8859_13 = 27 , /* ISO-8859-13 */
XML_CHAR_ENCODING_8859_14 = 28 , /* ISO-8859-14 */
XML_CHAR_ENCODING_8859_15 = 29 , /* ISO-8859-15 */
XML_CHAR_ENCODING_8859_16 = 30 /* ISO-8859-16 */
2001-02-23 20:55:21 +03:00
} xmlCharEncoding ;
/**
* xmlCharEncodingInputFunc :
2001-12-31 19:16:02 +03:00
* @ out : a pointer to an array of bytes to store the UTF - 8 result
2001-10-10 13:45:09 +04:00
* @ outlen : the length of @ out
2001-12-31 19:16:02 +03:00
* @ in : a pointer to an array of chars in the original encoding
2001-10-10 13:45:09 +04:00
* @ inlen : the length of @ in
2001-02-23 20:55:21 +03:00
*
2024-06-28 00:32:58 +03:00
* Convert characters to UTF - 8.
2001-02-23 20:55:21 +03:00
*
2024-06-28 00:32:58 +03:00
* On success , the value of @ inlen after return is the number of
* bytes consumed and @ outlen is the number of bytes produced .
*
* Returns the number of bytes written or an XML_ENC_ERR code .
2001-02-23 20:55:21 +03:00
*/
2024-06-28 00:32:58 +03:00
typedef int ( * xmlCharEncodingInputFunc ) ( unsigned char * out , int * outlen ,
const unsigned char * in , int * inlen ) ;
2001-02-23 20:55:21 +03:00
/**
* xmlCharEncodingOutputFunc :
2001-12-31 19:16:02 +03:00
* @ out : a pointer to an array of bytes to store the result
2001-10-10 13:45:09 +04:00
* @ outlen : the length of @ out
2001-12-31 19:16:02 +03:00
* @ in : a pointer to an array of UTF - 8 chars
2001-10-10 13:45:09 +04:00
* @ inlen : the length of @ in
2001-02-23 20:55:21 +03:00
*
2024-06-28 00:32:58 +03:00
* Convert characters from UTF - 8.
2001-02-23 20:55:21 +03:00
*
2024-06-28 00:32:58 +03:00
* On success , the value of @ inlen after return is the number of
* bytes consumed and @ outlen is the number of bytes produced .
*
* Returns the number of bytes written or an XML_ENC_ERR code .
2001-02-23 20:55:21 +03:00
*/
2024-06-28 00:32:58 +03:00
typedef int ( * xmlCharEncodingOutputFunc ) ( unsigned char * out , int * outlen ,
const unsigned char * in , int * inlen ) ;
2001-02-23 20:55:21 +03:00
2024-06-28 00:32:58 +03:00
/**
* xmlCharEncConvFunc :
* @ vctxt : conversion context
* @ out : a pointer to an array of bytes to store the result
* @ outlen : the length of @ out
* @ in : a pointer to an array of input bytes
* @ inlen : the length of @ in
*
* Convert between character encodings .
*
* On success , the value of @ inlen after return is the number of
* bytes consumed and @ outlen is the number of bytes produced .
*
* Returns the number of bytes written or an XML_ENC_ERR code .
*/
2024-06-27 22:37:18 +03:00
typedef int
2024-06-28 20:06:57 +03:00
( * xmlCharEncConvFunc ) ( unsigned char * out , int * outlen ,
const unsigned char * in , int * inlen , void * vctxt ) ;
2024-06-27 22:37:18 +03:00
2024-06-28 00:32:58 +03:00
/**
* xmlCharEncConvCtxtDtor :
* @ vctxt : conversion context
*
* Free a conversion context .
*/
2024-06-27 22:37:18 +03:00
typedef void
( * xmlCharEncConvCtxtDtor ) ( void * vctxt ) ;
2024-06-28 00:32:58 +03:00
typedef struct {
2024-06-28 20:06:57 +03:00
xmlCharEncConvFunc input ;
xmlCharEncConvFunc output ;
2024-06-28 00:32:58 +03:00
xmlCharEncConvCtxtDtor ctxtDtor ;
void * inputCtxt ;
void * outputCtxt ;
} xmlCharEncConverter ;
/**
* xmlCharEncConvImpl :
* vctxt : user data
* name : encoding name
* conv : pointer to xmlCharEncConverter struct
*
* If this function returns XML_ERR_OK , it must fill the @ conv struct
* with a conversion function , and optional destructor and optional
* input and output conversion contexts .
*
* Returns an xmlParserErrors code .
*/
typedef int
( * xmlCharEncConvImpl ) ( void * vctxt , const char * name ,
xmlCharEncConverter * conv ) ;
2001-02-23 20:55:21 +03:00
/*
* Block defining the handlers for non UTF - 8 encodings .
2024-06-27 22:37:18 +03:00
*
* This structure will be made private .
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler ;
typedef xmlCharEncodingHandler * xmlCharEncodingHandlerPtr ;
struct _xmlCharEncodingHandler {
2024-06-28 20:06:57 +03:00
char * name XML_DEPRECATED_MEMBER ;
xmlCharEncodingInputFunc input XML_DEPRECATED_MEMBER ;
xmlCharEncodingOutputFunc output XML_DEPRECATED_MEMBER ;
2001-02-23 20:55:21 +03:00
# ifdef LIBXML_ICONV_ENABLED
2024-06-28 22:51:21 +03:00
void * iconv_in XML_DEPRECATED_MEMBER ;
void * iconv_out XML_DEPRECATED_MEMBER ;
2001-02-23 20:55:21 +03:00
# endif /* LIBXML_ICONV_ENABLED */
2024-06-27 22:37:18 +03:00
void * inputCtxt XML_DEPRECATED_MEMBER ;
void * outputCtxt XML_DEPRECATED_MEMBER ;
2024-06-28 20:06:57 +03:00
xmlCharEncConvCtxtDtor ctxtDtor XML_DEPRECATED_MEMBER ;
int flags XML_DEPRECATED_MEMBER ;
2001-02-23 20:55:21 +03:00
} ;
/*
2002-03-12 21:46:39 +03:00
* Interfaces for encoding handlers .
2001-02-23 20:55:21 +03:00
*/
2022-03-06 15:55:48 +03:00
XML_DEPRECATED
2022-12-08 04:48:27 +03:00
XMLPUBFUN void
2003-08-25 13:05:12 +04:00
xmlInitCharEncodingHandlers ( void ) ;
2022-03-06 15:55:48 +03:00
XML_DEPRECATED
2022-12-08 04:48:27 +03:00
XMLPUBFUN void
2003-08-25 13:05:12 +04:00
xmlCleanupCharEncodingHandlers ( void ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN void
2003-08-25 13:05:12 +04:00
xmlRegisterCharEncodingHandler ( xmlCharEncodingHandlerPtr handler ) ;
2023-12-10 16:56:21 +03:00
XMLPUBFUN int
xmlLookupCharEncodingHandler ( xmlCharEncoding enc ,
xmlCharEncodingHandlerPtr * out ) ;
XMLPUBFUN int
xmlOpenCharEncodingHandler ( const char * name ,
2024-01-02 20:33:57 +03:00
int output ,
2023-12-10 16:56:21 +03:00
xmlCharEncodingHandlerPtr * out ) ;
2024-06-28 00:32:58 +03:00
XMLPUBFUN int
xmlCreateCharEncodingHandler ( const char * name ,
int output ,
xmlCharEncConvImpl impl ,
void * implCtxt ,
xmlCharEncodingHandlerPtr * out ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN xmlCharEncodingHandlerPtr
2001-02-23 20:55:21 +03:00
xmlGetCharEncodingHandler ( xmlCharEncoding enc ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN xmlCharEncodingHandlerPtr
2001-02-23 20:55:21 +03:00
xmlFindCharEncodingHandler ( const char * name ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN xmlCharEncodingHandlerPtr
2012-09-11 09:26:36 +04:00
xmlNewCharEncodingHandler ( const char * name ,
xmlCharEncodingInputFunc input ,
xmlCharEncodingOutputFunc output ) ;
2001-02-23 20:55:21 +03:00
/*
2002-03-12 21:46:39 +03:00
* Interfaces for encoding names and aliases .
2001-02-23 20:55:21 +03:00
*/
2022-12-08 04:48:27 +03:00
XMLPUBFUN int
2003-08-25 13:05:12 +04:00
xmlAddEncodingAlias ( const char * name ,
2001-02-23 20:55:21 +03:00
const char * alias ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN int
2003-08-25 13:05:12 +04:00
xmlDelEncodingAlias ( const char * alias ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN const char *
2001-02-23 20:55:21 +03:00
xmlGetEncodingAlias ( const char * alias ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN void
2003-08-25 13:05:12 +04:00
xmlCleanupEncodingAliases ( void ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN xmlCharEncoding
2002-01-21 01:08:18 +03:00
xmlParseCharEncoding ( const char * name ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN const char *
2001-02-23 20:55:21 +03:00
xmlGetCharEncodingName ( xmlCharEncoding enc ) ;
/*
* Interfaces directly used by the parsers .
*/
2022-12-08 04:48:27 +03:00
XMLPUBFUN xmlCharEncoding
2002-01-21 01:08:18 +03:00
xmlDetectCharEncoding ( const unsigned char * in ,
2001-02-23 20:55:21 +03:00
int len ) ;
2024-05-20 14:58:22 +03:00
/** DOC_DISABLE */
2023-09-20 18:38:26 +03:00
struct _xmlBuffer ;
2024-05-20 14:58:22 +03:00
/** DOC_ENABLE */
2022-12-08 04:48:27 +03:00
XMLPUBFUN int
2003-08-25 13:05:12 +04:00
xmlCharEncOutFunc ( xmlCharEncodingHandler * handler ,
2023-09-20 18:38:26 +03:00
struct _xmlBuffer * out ,
struct _xmlBuffer * in ) ;
2001-02-23 20:55:21 +03:00
2022-12-08 04:48:27 +03:00
XMLPUBFUN int
2003-08-25 13:05:12 +04:00
xmlCharEncInFunc ( xmlCharEncodingHandler * handler ,
2023-09-20 18:38:26 +03:00
struct _xmlBuffer * out ,
struct _xmlBuffer * in ) ;
2023-03-21 21:07:12 +03:00
XML_DEPRECATED
2022-12-08 04:48:27 +03:00
XMLPUBFUN int
2003-08-25 13:05:12 +04:00
xmlCharEncFirstLine ( xmlCharEncodingHandler * handler ,
2023-09-20 18:38:26 +03:00
struct _xmlBuffer * out ,
struct _xmlBuffer * in ) ;
2022-12-08 04:48:27 +03:00
XMLPUBFUN int
2003-08-25 13:05:12 +04:00
xmlCharEncCloseFunc ( xmlCharEncodingHandler * handler ) ;
2001-02-23 20:55:21 +03:00
2001-03-24 20:00:36 +03:00
/*
* Export a few useful functions
*/
Re-examined the problems of configuring a "minimal" library.
Synchronized the header files with the library code in order
to assure that all the various conditionals (LIBXML_xxxx_ENABLED)
were the same in both. Modified the API database content to more
accurately reflect the conditionals. Enhanced the generation
of that database. Although there was no substantial change to
any of the library code's logic, a large number of files were
modified to achieve the above, and the configuration script
was enhanced to do some automatic enabling of features (e.g.
--with-xinclude forces --with-xpath). Additionally, all the format
errors discovered by apibuild.py were corrected.
* configure.in: enhanced cross-checking of options
* doc/apibuild.py, doc/elfgcchack.xsl, doc/libxml2-refs.xml,
doc/libxml2-api.xml, gentest.py: changed the usage of the
<cond> element in module descriptions
* elfgcchack.h, testapi.c: regenerated with proper conditionals
* HTMLparser.c, SAX.c, globals.c, tree.c, xmlschemas.c, xpath.c,
testSAX.c: cleaned up conditionals
* include/libxml/[SAX.h, SAX2.h, debugXML.h, encoding.h, entities.h,
hash.h, parser.h, parserInternals.h, schemasInternals.h, tree.h,
valid.h, xlink.h, xmlIO.h, xmlautomata.h, xmlreader.h, xpath.h]:
synchronized the conditionals with the corresponding module code
* doc/examples/tree2.c, doc/examples/xpath1.c, doc/examples/xpath2.c:
added additional conditions required for compilation
* doc/*.html, doc/html/*.html: rebuilt the docs
2005-01-02 12:53:13 +03:00
# ifdef LIBXML_OUTPUT_ENABLED
2022-12-08 04:48:27 +03:00
XMLPUBFUN int
2003-08-25 13:05:12 +04:00
UTF8Toisolat1 ( unsigned char * out ,
2001-03-24 20:00:36 +03:00
int * outlen ,
2002-01-21 01:08:18 +03:00
const unsigned char * in ,
2001-03-24 20:00:36 +03:00
int * inlen ) ;
Re-examined the problems of configuring a "minimal" library.
Synchronized the header files with the library code in order
to assure that all the various conditionals (LIBXML_xxxx_ENABLED)
were the same in both. Modified the API database content to more
accurately reflect the conditionals. Enhanced the generation
of that database. Although there was no substantial change to
any of the library code's logic, a large number of files were
modified to achieve the above, and the configuration script
was enhanced to do some automatic enabling of features (e.g.
--with-xinclude forces --with-xpath). Additionally, all the format
errors discovered by apibuild.py were corrected.
* configure.in: enhanced cross-checking of options
* doc/apibuild.py, doc/elfgcchack.xsl, doc/libxml2-refs.xml,
doc/libxml2-api.xml, gentest.py: changed the usage of the
<cond> element in module descriptions
* elfgcchack.h, testapi.c: regenerated with proper conditionals
* HTMLparser.c, SAX.c, globals.c, tree.c, xmlschemas.c, xpath.c,
testSAX.c: cleaned up conditionals
* include/libxml/[SAX.h, SAX2.h, debugXML.h, encoding.h, entities.h,
hash.h, parser.h, parserInternals.h, schemasInternals.h, tree.h,
valid.h, xlink.h, xmlIO.h, xmlautomata.h, xmlreader.h, xpath.h]:
synchronized the conditionals with the corresponding module code
* doc/examples/tree2.c, doc/examples/xpath1.c, doc/examples/xpath2.c:
added additional conditions required for compilation
* doc/*.html, doc/html/*.html: rebuilt the docs
2005-01-02 12:53:13 +03:00
# endif /* LIBXML_OUTPUT_ENABLED */
2022-12-08 04:48:27 +03:00
XMLPUBFUN int
2003-08-25 13:05:12 +04:00
isolat1ToUTF8 ( unsigned char * out ,
2001-03-24 20:00:36 +03:00
int * outlen ,
2002-01-21 01:08:18 +03:00
const unsigned char * in ,
2001-03-24 20:00:36 +03:00
int * inlen ) ;
2001-02-23 20:55:21 +03:00
# ifdef __cplusplus
}
# endif
# endif /* __XML_CHAR_ENCODING_H__ */