1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/libxml2/libxml2_encoding.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,228 @@
1.4 +/*
1.5 + * Summary: interface for the encoding conversion functions
1.6 + * Description: interface for the encoding conversion functions needed for
1.7 + * XML basic encoding and iconv() support.
1.8 + *
1.9 + * Related specs are
1.10 + * rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies
1.11 + * [ISO-10646] UTF-8 and UTF-16 in Annexes
1.12 + * [ISO-8859-1] ISO Latin-1 characters codes.
1.13 + * [UNICODE] The Unicode Consortium, "The Unicode Standard --
1.14 + * Worldwide Character Encoding -- Version 1.0", Addison-
1.15 + * Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is
1.16 + * described in Unicode Technical Report #4.
1.17 + * [US-ASCII] Coded Character Set--7-bit American Standard Code for
1.18 + * Information Interchange, ANSI X3.4-1986.
1.19 + *
1.20 + * Copy: See Copyright for the status of this software.
1.21 + *
1.22 + * Author: Daniel Veillard
1.23 + * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.24 + */
1.25 +
1.26 +/** @file
1.27 +@publishedAll
1.28 +@released
1.29 +*/
1.30 +
1.31 +#ifndef XML_CHAR_ENCODING_H
1.32 +#define XML_CHAR_ENCODING_H
1.33 +
1.34 +//#include "libxml/Libxml2_xmlversion.h" // enable this when dependency on tree.h is removed
1.35 +#include "libxml2_tree.h"
1.36 +
1.37 +#ifdef LIBXML_ICONV_ENABLED
1.38 +#include <iconv.h>
1.39 +#endif
1.40 +
1.41 +#ifdef __cplusplus
1.42 +extern "C" {
1.43 +#endif
1.44 +
1.45 +/*
1.46 + * xmlCharEncoding:
1.47 + *
1.48 + * Predefined values for some standard encodings.
1.49 + * Libxml does not do beforehand translation on UTF8 and ISOLatinX.
1.50 + * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default.
1.51 + *
1.52 + * Anything else would have to be translated to UTF8 before being
1.53 + * given to the parser itself. The BOM for UTF16 and the encoding
1.54 + * declaration are looked at and a converter is looked for at that
1.55 + * point. If not found the parser stops here as asked by the XML REC. A
1.56 + * converter can be registered by the user using xmlRegisterCharEncodingHandler
1.57 + * but the current form doesn't allow stateful transcoding (a serious
1.58 + * problem agreed !). If iconv has been found it will be used
1.59 + * automatically and allow stateful transcoding, the simplest is then
1.60 + * to be sure to enable iconv and to provide iconv libs for the encoding
1.61 + * support needed.
1.62 + *
1.63 + * Note that the generic "UTF-16" is not a predefined value. Instead, only
1.64 + * the specific UTF-16LE and UTF-16BE are present.
1.65 + */
1.66 +typedef enum {
1.67 + XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */
1.68 + XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */
1.69 + XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */
1.70 + XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */
1.71 + XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */
1.72 + XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */
1.73 + XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */
1.74 + XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */
1.75 + XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
1.76 + XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
1.77 + XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */
1.78 + XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */
1.79 + XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */
1.80 + XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */
1.81 + XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */
1.82 + XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */
1.83 + XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */
1.84 + XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */
1.85 + XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */
1.86 + XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */
1.87 + XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */
1.88 + XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
1.89 + XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */
1.90 + XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */
1.91 +} xmlCharEncoding;
1.92 +
1.93 +/**
1.94 + * xmlCharEncodingInputFunc:
1.95 + * @param out a pointer to an array of bytes to store the UTF-8 result
1.96 + * @param outlen the length of out
1.97 + * @param in a pointer to an array of chars in the original encoding
1.98 + * @param inlen the length of in
1.99 + *
1.100 + * Take a block of chars in the original encoding and try to convert
1.101 + * it to an UTF-8 block of chars out.
1.102 + *
1.103 + * Returns the number of bytes written, -1 if lack of space, or -2
1.104 + * if the transcoding failed.
1.105 + * The value of inlen after return is the number of octets consumed
1.106 + * if the return value is positive, else unpredictiable.
1.107 + * The value of outlen after return is the number of octets consumed.
1.108 + */
1.109 +typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
1.110 + const unsigned char *in, int *inlen);
1.111 +
1.112 +
1.113 +/**
1.114 + * xmlCharEncodingOutputFunc:
1.115 + * @param out a pointer to an array of bytes to store the result
1.116 + * @param outlen the length of out
1.117 + * @param in a pointer to an array of UTF-8 chars
1.118 + * @param inlen the length of in
1.119 + *
1.120 + * Take a block of UTF-8 chars in and try to convert it to another
1.121 + * encoding.
1.122 + * Note: a first call designed to produce heading info is called with
1.123 + * in = NULL. If stateful this should also initialize the encoder state.
1.124 + *
1.125 + * Returns the number of bytes written, -1 if lack of space, or -2
1.126 + * if the transcoding failed.
1.127 + * The value of inlen after return is the number of octets consumed
1.128 + * if the return value is positive, else unpredictiable.
1.129 + * The value of outlen after return is the number of octets produced.
1.130 + */
1.131 +typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
1.132 + const unsigned char *in, int *inlen);
1.133 +
1.134 +
1.135 +/*
1.136 + * Block defining the handlers for non UTF-8 encodings.
1.137 + * If iconv is supported, there are two extra fields.
1.138 + */
1.139 +
1.140 +typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
1.141 +typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
1.142 +struct _xmlCharEncodingHandler {
1.143 + char *name;
1.144 + xmlCharEncodingInputFunc input;
1.145 + xmlCharEncodingOutputFunc output;
1.146 +#ifdef LIBXML_ICONV_ENABLED
1.147 + iconv_t iconv_in;
1.148 + iconv_t iconv_out;
1.149 +#endif /* LIBXML_ICONV_ENABLED */
1.150 +};
1.151 +
1.152 +//#ifdef __cplusplus
1.153 +//}
1.154 +//#endif
1.155 +//#ifdef __cplusplus
1.156 +//extern "C" {
1.157 +//#endif
1.158 +
1.159 +/*
1.160 + * Interfaces for encoding handlers.
1.161 + */
1.162 +XMLPUBFUN void XMLCALL
1.163 + xmlInitCharEncodingHandlers (void);
1.164 +XMLPUBFUN void XMLCALL
1.165 + xmlCleanupCharEncodingHandlers (void);
1.166 +XMLPUBFUN void XMLCALL
1.167 + xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
1.168 +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
1.169 + xmlGetCharEncodingHandler (xmlCharEncoding enc);
1.170 +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
1.171 + xmlFindCharEncodingHandler (const char *name);
1.172 +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
1.173 + xmlNewCharEncodingHandler (const char *name,
1.174 + xmlCharEncodingInputFunc input,
1.175 + xmlCharEncodingOutputFunc output);
1.176 +
1.177 +/*
1.178 + * Interfaces for encoding names and aliases.
1.179 + */
1.180 +#ifndef XMLENGINE_EXCLUDE_UNUSED
1.181 +XMLPUBFUN int XMLCALL xmlAddEncodingAlias(const char *name, const char *alias);
1.182 +XMLPUBFUN int XMLCALL xmlDelEncodingAlias(const char *alias);
1.183 +#endif
1.184 +
1.185 +XMLPUBFUN const char * XMLCALL xmlGetEncodingAlias (const char *alias);
1.186 +XMLPUBFUN void XMLCALL xmlCleanupEncodingAliases (void);
1.187 +XMLPUBFUN xmlCharEncoding XMLCALL xmlParseCharEncoding (const char *name);
1.188 +XMLPUBFUN const char * XMLCALL xmlGetCharEncodingName (xmlCharEncoding enc);
1.189 +
1.190 +/*
1.191 + * Interfaces directly used by the parsers.
1.192 + */
1.193 +XMLPUBFUN xmlCharEncoding XMLCALL
1.194 + xmlDetectCharEncoding (const unsigned char *in,
1.195 + int len);
1.196 +
1.197 +XMLPUBFUN int XMLCALL
1.198 + xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
1.199 + xmlBufferPtr out,
1.200 + xmlBufferPtr in);
1.201 +
1.202 +XMLPUBFUN int XMLCALL
1.203 + xmlCharEncInFunc (xmlCharEncodingHandler *handler,
1.204 + xmlBufferPtr out,
1.205 + xmlBufferPtr in);
1.206 +XMLPUBFUN int XMLCALL
1.207 + xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
1.208 + xmlBufferPtr out,
1.209 + xmlBufferPtr in);
1.210 +XMLPUBFUN int XMLCALL
1.211 + xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
1.212 +
1.213 +/*
1.214 + * Export a few useful functions
1.215 + */
1.216 +XMLPUBFUN int XMLCALL
1.217 + UTF8Toisolat1 (unsigned char *out,
1.218 + int *outlen,
1.219 + const unsigned char *in,
1.220 + int *inlen);
1.221 +XMLPUBFUN int XMLCALL
1.222 + isolat1ToUTF8 (unsigned char *out,
1.223 + int *outlen,
1.224 + const unsigned char *in,
1.225 + int *inlen);
1.226 +#ifdef __cplusplus
1.227 +}
1.228 +#endif
1.229 +
1.230 +#endif /* XML_CHAR_ENCODING_H */
1.231 +