Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

encoding.h

Go to the documentation of this file.
00001 /*
00002  * encoding.h : interface for the encoding conversion functions needed for
00003  *              XML
00004  *
00005  * Related specs: 
00006  * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies
00007  * [ISO-10646]    UTF-8 and UTF-16 in Annexes
00008  * [ISO-8859-1]   ISO Latin-1 characters codes.
00009  * [UNICODE]      The Unicode Consortium, "The Unicode Standard --
00010  *                Worldwide Character Encoding -- Version 1.0", Addison-
00011  *                Wesley, Volume 1, 1991, Volume 2, 1992.  UTF-8 is
00012  *                described in Unicode Technical Report #4.
00013  * [US-ASCII]     Coded Character Set--7-bit American Standard Code for
00014  *                Information Interchange, ANSI X3.4-1986.
00015  *
00016  * See Copyright for the status of this software.
00017  *
00018  * daniel@veillard.com
00019  */
00020 
00021 #ifndef __XML_CHAR_ENCODING_H__
00022 #define __XML_CHAR_ENCODING_H__
00023 
00024 #include <libxml/xmlversion.h>
00025 
00026 #ifdef LIBXML_ICONV_ENABLED
00027 #include <iconv.h>
00028 #endif
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00051 typedef enum {
00052     XML_CHAR_ENCODING_ERROR=   -1, /* No char encoding detected */
00053     XML_CHAR_ENCODING_NONE=     0, /* No char encoding detected */
00054     XML_CHAR_ENCODING_UTF8=     1, /* UTF-8 */
00055     XML_CHAR_ENCODING_UTF16LE=  2, /* UTF-16 little endian */
00056     XML_CHAR_ENCODING_UTF16BE=  3, /* UTF-16 big endian */
00057     XML_CHAR_ENCODING_UCS4LE=   4, /* UCS-4 little endian */
00058     XML_CHAR_ENCODING_UCS4BE=   5, /* UCS-4 big endian */
00059     XML_CHAR_ENCODING_EBCDIC=   6, /* EBCDIC uh! */
00060     XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
00061     XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
00062     XML_CHAR_ENCODING_UCS2=     9, /* UCS-2 */
00063     XML_CHAR_ENCODING_8859_1=   10,/* ISO-8859-1 ISO Latin 1 */
00064     XML_CHAR_ENCODING_8859_2=   11,/* ISO-8859-2 ISO Latin 2 */
00065     XML_CHAR_ENCODING_8859_3=   12,/* ISO-8859-3 */
00066     XML_CHAR_ENCODING_8859_4=   13,/* ISO-8859-4 */
00067     XML_CHAR_ENCODING_8859_5=   14,/* ISO-8859-5 */
00068     XML_CHAR_ENCODING_8859_6=   15,/* ISO-8859-6 */
00069     XML_CHAR_ENCODING_8859_7=   16,/* ISO-8859-7 */
00070     XML_CHAR_ENCODING_8859_8=   17,/* ISO-8859-8 */
00071     XML_CHAR_ENCODING_8859_9=   18,/* ISO-8859-9 */
00072     XML_CHAR_ENCODING_2022_JP=  19,/* ISO-2022-JP */
00073     XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
00074     XML_CHAR_ENCODING_EUC_JP=   21,/* EUC-JP */
00075     XML_CHAR_ENCODING_ASCII=    22 /* pure ASCII */
00076 } xmlCharEncoding;
00077 
00094 typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
00095                                          const unsigned char *in, int *inlen);
00096 
00097 
00116 typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
00117                                           const unsigned char *in, int *inlen);
00118 
00119 
00120 /*
00121  * Block defining the handlers for non UTF-8 encodings.
00122  * If iconv is supported, there is two extra fields.
00123  */
00124 
00125 typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
00126 typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
00127 struct _xmlCharEncodingHandler {
00128     char                       *name;
00129     xmlCharEncodingInputFunc   input;
00130     xmlCharEncodingOutputFunc  output;
00131 #ifdef LIBXML_ICONV_ENABLED
00132     iconv_t                    iconv_in;
00133     iconv_t                    iconv_out;
00134 #endif /* LIBXML_ICONV_ENABLED */
00135 };
00136 
00137 #ifdef __cplusplus
00138 }
00139 #endif
00140 #include <libxml/tree.h>
00141 #ifdef __cplusplus
00142 extern "C" {
00143 #endif
00144 
00145 /*
00146  * Interfaces for encoding handlers.
00147  */
00148 XMLPUBFUN void XMLCALL  
00149         xmlInitCharEncodingHandlers     (void);
00150 XMLPUBFUN void XMLCALL  
00151         xmlCleanupCharEncodingHandlers  (void);
00152 XMLPUBFUN void XMLCALL  
00153         xmlRegisterCharEncodingHandler  (xmlCharEncodingHandlerPtr handler);
00154 XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
00155         xmlGetCharEncodingHandler       (xmlCharEncoding enc);
00156 XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
00157         xmlFindCharEncodingHandler      (const char *name);
00158 XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
00159         xmlNewCharEncodingHandler       (const char *name, 
00160                                          xmlCharEncodingInputFunc input,
00161                                          xmlCharEncodingOutputFunc output);
00162 
00163 /*
00164  * Interfaces for encoding names and aliases.
00165  */
00166 XMLPUBFUN int XMLCALL   
00167         xmlAddEncodingAlias             (const char *name,
00168                                          const char *alias);
00169 XMLPUBFUN int XMLCALL   
00170         xmlDelEncodingAlias             (const char *alias);
00171 XMLPUBFUN const char * XMLCALL
00172         xmlGetEncodingAlias             (const char *alias);
00173 XMLPUBFUN void XMLCALL  
00174         xmlCleanupEncodingAliases       (void);
00175 XMLPUBFUN xmlCharEncoding XMLCALL
00176         xmlParseCharEncoding            (const char *name);
00177 XMLPUBFUN const char * XMLCALL
00178         xmlGetCharEncodingName          (xmlCharEncoding enc);
00179 
00180 /*
00181  * Interfaces directly used by the parsers.
00182  */
00183 XMLPUBFUN xmlCharEncoding XMLCALL
00184         xmlDetectCharEncoding           (const unsigned char *in,
00185                                          int len);
00186 
00187 XMLPUBFUN int XMLCALL   
00188         xmlCharEncOutFunc               (xmlCharEncodingHandler *handler,
00189                                          xmlBufferPtr out,
00190                                          xmlBufferPtr in);
00191 
00192 XMLPUBFUN int XMLCALL   
00193         xmlCharEncInFunc                (xmlCharEncodingHandler *handler,
00194                                          xmlBufferPtr out,
00195                                          xmlBufferPtr in);
00196 XMLPUBFUN int XMLCALL
00197         xmlCharEncFirstLine             (xmlCharEncodingHandler *handler,
00198                                          xmlBufferPtr out,
00199                                          xmlBufferPtr in);
00200 XMLPUBFUN int XMLCALL   
00201         xmlCharEncCloseFunc             (xmlCharEncodingHandler *handler);
00202 
00203 /*
00204  * Export a few useful functions
00205  */
00206 XMLPUBFUN int XMLCALL   
00207         UTF8Toisolat1                   (unsigned char *out,
00208                                          int *outlen,
00209                                          const unsigned char *in,
00210                                          int *inlen);
00211 XMLPUBFUN int XMLCALL   
00212         isolat1ToUTF8                   (unsigned char *out,
00213                                          int *outlen,
00214                                          const unsigned char *in,
00215                                          int *inlen);
00216 XMLPUBFUN int XMLCALL   
00217         xmlGetUTF8Char                  (const unsigned char *utf,
00218                                          int *len);
00219 /*
00220  * exports additional "UTF-8 aware" string routines which are.
00221  */
00222 
00223 XMLPUBFUN int XMLCALL   
00224         xmlCheckUTF8                    (const unsigned char *utf);
00225 XMLPUBFUN int XMLCALL   
00226         xmlUTF8Strsize                  (const xmlChar *utf,
00227                                          int len);
00228 XMLPUBFUN xmlChar * XMLCALL 
00229         xmlUTF8Strndup                  (const xmlChar *utf,
00230                                          int len);
00231 XMLPUBFUN xmlChar * XMLCALL 
00232         xmlUTF8Strpos                   (const xmlChar *utf,
00233                                          int pos);
00234 XMLPUBFUN int XMLCALL   
00235         xmlUTF8Strloc                   (const xmlChar *utf,
00236                                          const xmlChar *utfchar);
00237 XMLPUBFUN xmlChar * XMLCALL 
00238         xmlUTF8Strsub                   (const xmlChar *utf,
00239                                          int start,
00240                                          int len);
00241 XMLPUBFUN int XMLCALL   
00242         xmlUTF8Strlen                   (const xmlChar *utf);
00243 XMLPUBFUN int XMLCALL   
00244         xmlUTF8Size                     (const xmlChar *utf);
00245 XMLPUBFUN int XMLCALL   
00246         xmlUTF8Charcmp                  (const xmlChar *utf1,
00247                                          const xmlChar *utf2);
00248 #ifdef __cplusplus
00249 }
00250 #endif
00251 
00252 #endif /* __XML_CHAR_ENCODING_H__ */
00253 

Generated on Wed Mar 16 00:10:26 2005 for Dibbler - a portable DHCPv6 by  doxygen 1.3.9.1