2001-02-23 17:55:21 +00:00
/*
2003-11-18 20:56:51 +00: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 17:55:21 +00:00
*
2003-11-18 20:56:51 +00:00
* Related specs are
2001-02-23 17:55:21 +00: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 20:56:51 +00:00
* Copy : See Copyright for the status of this software .
2001-02-23 17:55:21 +00:00
*
2003-11-18 20:56:51 +00:00
* Author : Daniel Veillard
2001-02-23 17:55:21 +00:00
*/
# ifndef __XML_CHAR_ENCODING_H__
# define __XML_CHAR_ENCODING_H__
# include <libxml/xmlversion.h>
2002-11-08 17:18:52 +00:00
2001-02-23 17:55:21 +00:00
# ifdef LIBXML_ICONV_ENABLED
# include <iconv.h>
# endif
# ifdef __cplusplus
extern " C " {
# endif
2003-11-16 06:25:42 +00:00
/*
2001-05-19 13:24:56 +00:00
* xmlCharEncoding :
*
2002-03-12 18:46:39 +00:00
* Predefined values for some standard encodings .
2003-11-28 09:39:10 +00:00
* Libxml does not do beforehand translation on UTF8 and ISOLatinX .
* It also supports ASCII , ISO - 8859 - 1 , and UTF16 ( LE and BE ) by default .
2001-02-23 17:55:21 +00:00
*
* Anything else would have to be translated to UTF8 before being
* given to the parser itself . The BOM for UTF16 and the encoding
* declaration are looked at and a converter is looked for at that
2003-11-28 09:39:10 +00:00
* point . If not found the parser stops here as asked by the XML REC . A
* converter can be registered by the user using xmlRegisterCharEncodingHandler
2001-12-31 16:16:02 +00:00
* but the current form doesn ' t allow stateful transcoding ( a serious
2001-02-23 17:55:21 +00:00
* problem agreed ! ) . If iconv has been found it will be used
* automatically and allow stateful transcoding , the simplest is then
2003-11-28 09:39:10 +00:00
* to be sure to enable iconv and to provide iconv libs for the encoding
2001-02-23 17:55:21 +00:00
* support needed .
2003-11-28 09:39:10 +00:00
*
* Note that the generic " UTF-16 " is not a predefined value . Instead , only
* the specific UTF - 16L E and UTF - 16 BE are present .
2001-02-23 17:55:21 +00: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 */
XML_CHAR_ENCODING_ASCII = 22 /* pure ASCII */
} xmlCharEncoding ;
/**
* xmlCharEncodingInputFunc :
2001-12-31 16:16:02 +00:00
* @ out : a pointer to an array of bytes to store the UTF - 8 result
2001-10-10 09:45:09 +00:00
* @ outlen : the length of @ out
2001-12-31 16:16:02 +00:00
* @ in : a pointer to an array of chars in the original encoding
2001-10-10 09:45:09 +00:00
* @ inlen : the length of @ in
2001-02-23 17:55:21 +00:00
*
* Take a block of chars in the original encoding and try to convert
* it to an UTF - 8 block of chars out .
*
2003-11-28 09:39:10 +00:00
* Returns the number of bytes written , - 1 if lack of space , or - 2
2001-02-23 17:55:21 +00:00
* if the transcoding failed .
* The value of @ inlen after return is the number of octets consumed
2003-11-28 09:39:10 +00:00
* if the return value is positive , else unpredictiable .
2001-12-31 16:16:02 +00:00
* The value of @ outlen after return is the number of octets consumed .
2001-02-23 17:55:21 +00:00
*/
2002-01-20 22:08:18 +00:00
typedef int ( * xmlCharEncodingInputFunc ) ( unsigned char * out , int * outlen ,
const unsigned char * in , int * inlen ) ;
2001-02-23 17:55:21 +00:00
/**
* xmlCharEncodingOutputFunc :
2001-12-31 16:16:02 +00:00
* @ out : a pointer to an array of bytes to store the result
2001-10-10 09:45:09 +00:00
* @ outlen : the length of @ out
2001-12-31 16:16:02 +00:00
* @ in : a pointer to an array of UTF - 8 chars
2001-10-10 09:45:09 +00:00
* @ inlen : the length of @ in
2001-02-23 17:55:21 +00:00
*
2003-11-28 09:39:10 +00:00
* Take a block of UTF - 8 chars in and try to convert it to another
2001-02-23 17:55:21 +00:00
* encoding .
* Note : a first call designed to produce heading info is called with
2002-03-12 18:46:39 +00:00
* in = NULL . If stateful this should also initialize the encoder state .
2001-02-23 17:55:21 +00:00
*
2003-11-28 09:39:10 +00:00
* Returns the number of bytes written , - 1 if lack of space , or - 2
2001-02-23 17:55:21 +00:00
* if the transcoding failed .
* The value of @ inlen after return is the number of octets consumed
2003-11-28 09:39:10 +00:00
* if the return value is positive , else unpredictiable .
2004-02-11 13:25:26 +00:00
* The value of @ outlen after return is the number of octets produced .
2001-02-23 17:55:21 +00:00
*/
2002-01-20 22:08:18 +00:00
typedef int ( * xmlCharEncodingOutputFunc ) ( unsigned char * out , int * outlen ,
const unsigned char * in , int * inlen ) ;
2001-02-23 17:55:21 +00:00
/*
* Block defining the handlers for non UTF - 8 encodings .
2003-11-28 09:39:10 +00:00
* If iconv is supported , there are two extra fields .
2001-02-23 17:55:21 +00:00
*/
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler ;
typedef xmlCharEncodingHandler * xmlCharEncodingHandlerPtr ;
struct _xmlCharEncodingHandler {
char * name ;
xmlCharEncodingInputFunc input ;
xmlCharEncodingOutputFunc output ;
# ifdef LIBXML_ICONV_ENABLED
iconv_t iconv_in ;
iconv_t iconv_out ;
# endif /* LIBXML_ICONV_ENABLED */
} ;
2002-02-11 08:54:05 +00:00
# ifdef __cplusplus
}
# endif
# include <libxml/tree.h>
# ifdef __cplusplus
extern " C " {
# endif
2001-02-23 17:55:21 +00:00
/*
2002-03-12 18:46:39 +00:00
* Interfaces for encoding handlers .
2001-02-23 17:55:21 +00:00
*/
2003-08-25 09:05:12 +00:00
XMLPUBFUN void XMLCALL
xmlInitCharEncodingHandlers ( void ) ;
XMLPUBFUN void XMLCALL
xmlCleanupCharEncodingHandlers ( void ) ;
XMLPUBFUN void XMLCALL
xmlRegisterCharEncodingHandler ( xmlCharEncodingHandlerPtr handler ) ;
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
2001-02-23 17:55:21 +00:00
xmlGetCharEncodingHandler ( xmlCharEncoding enc ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
2001-02-23 17:55:21 +00:00
xmlFindCharEncodingHandler ( const char * name ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
2002-08-01 12:22:24 +00:00
xmlNewCharEncodingHandler ( const char * name ,
xmlCharEncodingInputFunc input ,
xmlCharEncodingOutputFunc output ) ;
2001-02-23 17:55:21 +00:00
/*
2002-03-12 18:46:39 +00:00
* Interfaces for encoding names and aliases .
2001-02-23 17:55:21 +00:00
*/
2003-08-25 09:05:12 +00:00
XMLPUBFUN int XMLCALL
xmlAddEncodingAlias ( const char * name ,
2001-02-23 17:55:21 +00:00
const char * alias ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN int XMLCALL
xmlDelEncodingAlias ( const char * alias ) ;
XMLPUBFUN const char * XMLCALL
2001-02-23 17:55:21 +00:00
xmlGetEncodingAlias ( const char * alias ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN void XMLCALL
xmlCleanupEncodingAliases ( void ) ;
XMLPUBFUN xmlCharEncoding XMLCALL
2002-01-20 22:08:18 +00:00
xmlParseCharEncoding ( const char * name ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN const char * XMLCALL
2001-02-23 17:55:21 +00:00
xmlGetCharEncodingName ( xmlCharEncoding enc ) ;
/*
* Interfaces directly used by the parsers .
*/
2003-08-25 09:05:12 +00:00
XMLPUBFUN xmlCharEncoding XMLCALL
2002-01-20 22:08:18 +00:00
xmlDetectCharEncoding ( const unsigned char * in ,
2001-02-23 17:55:21 +00:00
int len ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN int XMLCALL
xmlCharEncOutFunc ( xmlCharEncodingHandler * handler ,
2001-02-23 17:55:21 +00:00
xmlBufferPtr out ,
xmlBufferPtr in ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN int XMLCALL
xmlCharEncInFunc ( xmlCharEncodingHandler * handler ,
2001-02-23 17:55:21 +00:00
xmlBufferPtr out ,
xmlBufferPtr in ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN int XMLCALL
xmlCharEncFirstLine ( xmlCharEncodingHandler * handler ,
2001-02-23 17:55:21 +00:00
xmlBufferPtr out ,
xmlBufferPtr in ) ;
2003-08-25 09:05:12 +00:00
XMLPUBFUN int XMLCALL
xmlCharEncCloseFunc ( xmlCharEncodingHandler * handler ) ;
2001-02-23 17:55:21 +00:00
2001-03-24 17:00:36 +00: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 09:53:13 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
2003-08-25 09:05:12 +00:00
XMLPUBFUN int XMLCALL
UTF8Toisolat1 ( unsigned char * out ,
2001-03-24 17:00:36 +00:00
int * outlen ,
2002-01-20 22:08:18 +00:00
const unsigned char * in ,
2001-03-24 17:00:36 +00: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 09:53:13 +00:00
# endif /* LIBXML_OUTPUT_ENABLED */
2003-08-25 09:05:12 +00:00
XMLPUBFUN int XMLCALL
isolat1ToUTF8 ( unsigned char * out ,
2001-03-24 17:00:36 +00:00
int * outlen ,
2002-01-20 22:08:18 +00:00
const unsigned char * in ,
2001-03-24 17:00:36 +00:00
int * inlen ) ;
2001-02-23 17:55:21 +00:00
# ifdef __cplusplus
}
# endif
# endif /* __XML_CHAR_ENCODING_H__ */