Hash :
1167c334
Author :
Date :
2024-06-28T21:51:21
encoding: Don't include iconv.h from libxml/encoding.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
/*
* Summary: interface for the encoding conversion functions
* Description: interface for the encoding conversion functions needed for
* XML basic encoding and iconv() support.
*
* Related specs are
* 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.
*
* Copy: See Copyright for the status of this software.
*
* Author: Daniel Veillard
*/
#ifndef __XML_CHAR_ENCODING_H__
#define __XML_CHAR_ENCODING_H__
#include <libxml/xmlversion.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
XML_ENC_ERR_SUCCESS = 0,
XML_ENC_ERR_INTERNAL = -1,
XML_ENC_ERR_INPUT = -2,
XML_ENC_ERR_SPACE = -3,
XML_ENC_ERR_MEMORY = -4
} xmlCharEncError;
/*
* xmlCharEncoding:
*
* Predefined values for some standard encodings.
*/
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 */
/* 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 */
} xmlCharEncoding;
/**
* xmlCharEncodingInputFunc:
* @out: a pointer to an array of bytes to store the UTF-8 result
* @outlen: the length of @out
* @in: a pointer to an array of chars in the original encoding
* @inlen: the length of @in
*
* Convert characters to UTF-8.
*
* 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.
*/
typedef int (*xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen);
/**
* xmlCharEncodingOutputFunc:
* @out: a pointer to an array of bytes to store the result
* @outlen: the length of @out
* @in: a pointer to an array of UTF-8 chars
* @inlen: the length of @in
*
* Convert characters from UTF-8.
*
* 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.
*/
typedef int (*xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen);
/**
* 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.
*/
typedef int
(*xmlCharEncConvFunc)(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, void *vctxt);
/**
* xmlCharEncConvCtxtDtor:
* @vctxt: conversion context
*
* Free a conversion context.
*/
typedef void
(*xmlCharEncConvCtxtDtor)(void *vctxt);
typedef struct {
xmlCharEncConvFunc input;
xmlCharEncConvFunc output;
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);
/*
* Block defining the handlers for non UTF-8 encodings.
*
* This structure will be made private.
*/
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
struct _xmlCharEncodingHandler {
char *name XML_DEPRECATED_MEMBER;
xmlCharEncodingInputFunc input XML_DEPRECATED_MEMBER;
xmlCharEncodingOutputFunc output XML_DEPRECATED_MEMBER;
#ifdef LIBXML_ICONV_ENABLED
void *iconv_in XML_DEPRECATED_MEMBER;
void *iconv_out XML_DEPRECATED_MEMBER;
#endif /* LIBXML_ICONV_ENABLED */
void *inputCtxt XML_DEPRECATED_MEMBER;
void *outputCtxt XML_DEPRECATED_MEMBER;
xmlCharEncConvCtxtDtor ctxtDtor XML_DEPRECATED_MEMBER;
int flags XML_DEPRECATED_MEMBER;
};
/*
* Interfaces for encoding handlers.
*/
XML_DEPRECATED
XMLPUBFUN void
xmlInitCharEncodingHandlers (void);
XML_DEPRECATED
XMLPUBFUN void
xmlCleanupCharEncodingHandlers (void);
XMLPUBFUN void
xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
XMLPUBFUN int
xmlLookupCharEncodingHandler (xmlCharEncoding enc,
xmlCharEncodingHandlerPtr *out);
XMLPUBFUN int
xmlOpenCharEncodingHandler (const char *name,
int output,
xmlCharEncodingHandlerPtr *out);
XMLPUBFUN int
xmlCreateCharEncodingHandler (const char *name,
int output,
xmlCharEncConvImpl impl,
void *implCtxt,
xmlCharEncodingHandlerPtr *out);
XMLPUBFUN xmlCharEncodingHandlerPtr
xmlGetCharEncodingHandler (xmlCharEncoding enc);
XMLPUBFUN xmlCharEncodingHandlerPtr
xmlFindCharEncodingHandler (const char *name);
XMLPUBFUN xmlCharEncodingHandlerPtr
xmlNewCharEncodingHandler (const char *name,
xmlCharEncodingInputFunc input,
xmlCharEncodingOutputFunc output);
/*
* Interfaces for encoding names and aliases.
*/
XMLPUBFUN int
xmlAddEncodingAlias (const char *name,
const char *alias);
XMLPUBFUN int
xmlDelEncodingAlias (const char *alias);
XMLPUBFUN const char *
xmlGetEncodingAlias (const char *alias);
XMLPUBFUN void
xmlCleanupEncodingAliases (void);
XMLPUBFUN xmlCharEncoding
xmlParseCharEncoding (const char *name);
XMLPUBFUN const char *
xmlGetCharEncodingName (xmlCharEncoding enc);
/*
* Interfaces directly used by the parsers.
*/
XMLPUBFUN xmlCharEncoding
xmlDetectCharEncoding (const unsigned char *in,
int len);
/** DOC_DISABLE */
struct _xmlBuffer;
/** DOC_ENABLE */
XMLPUBFUN int
xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
struct _xmlBuffer *out,
struct _xmlBuffer *in);
XMLPUBFUN int
xmlCharEncInFunc (xmlCharEncodingHandler *handler,
struct _xmlBuffer *out,
struct _xmlBuffer *in);
XML_DEPRECATED
XMLPUBFUN int
xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
struct _xmlBuffer *out,
struct _xmlBuffer *in);
XMLPUBFUN int
xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
/*
* Export a few useful functions
*/
#ifdef LIBXML_OUTPUT_ENABLED
XMLPUBFUN int
UTF8Toisolat1 (unsigned char *out,
int *outlen,
const unsigned char *in,
int *inlen);
#endif /* LIBXML_OUTPUT_ENABLED */
XMLPUBFUN int
isolat1ToUTF8 (unsigned char *out,
int *outlen,
const unsigned char *in,
int *inlen);
#ifdef __cplusplus
}
#endif
#endif /* __XML_CHAR_ENCODING_H__ */