ReactOS 0.4.16-dev-319-g6cf4263
|
#include "libxml.h"
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <stdlib.h>
#include <libxml/encoding.h>
#include <libxml/xmlmemory.h>
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
#include "buf.h"
#include "enc.h"
Go to the source code of this file.
Classes | |
struct | _xmlCharEncodingAlias |
Macros | |
#define | IN_LIBXML |
Typedefs | |
typedef struct _xmlCharEncodingAlias | xmlCharEncodingAlias |
typedef xmlCharEncodingAlias * | xmlCharEncodingAliasPtr |
Variables | |
static xmlCharEncodingHandlerPtr | xmlUTF16LEHandler = NULL |
static xmlCharEncodingHandlerPtr | xmlUTF16BEHandler = NULL |
static xmlCharEncodingAliasPtr | xmlCharEncodingAliases = NULL |
static int | xmlCharEncodingAliasesNb = 0 |
static int | xmlCharEncodingAliasesMax = 0 |
static int | xmlLittleEndian = 1 |
: the encoding name as parsed, in UTF-8 format (ASCII actually) | |
xmlParseCharEncoding: Compare the string to the encoding schemes already known. Note that the comparison is case insensitive accordingly to the section [XML] 4.3.3 Character Encoding in Entities. Returns one of the XML_CHAR_ENCODING_... values or XML_CHAR_ENCODING_NONE if not recognized. | |
#define | MAX_ENCODING_HANDLERS 50 |
static xmlCharEncodingHandlerPtr * | handlers = NULL |
static int | nbCharEncodingHandler = 0 |
static xmlCharEncodingHandlerPtr | xmlDefaultCharEncodingHandler = NULL |
xmlCharEncoding | xmlParseCharEncoding (const char *name) |
const char * | xmlGetCharEncodingName (xmlCharEncoding enc) |
#define IN_LIBXML |
Definition at line 23 of file encoding.c.
#define MAX_ENCODING_HANDLERS 50 |
Definition at line 1316 of file encoding.c.
Definition at line 63 of file encoding.c.
Definition at line 64 of file encoding.c.
|
static |
asciiToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @in: a pointer to an array of ASCII chars @inlen: the length of @in
Take a block of ASCII chars in and try to convert it to an UTF-8 block of chars out. Returns 0 if success, or -1 otherwise The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.
Definition at line 185 of file encoding.c.
Referenced by xmlInitCharEncodingHandlers().
isolat1ToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @in: a pointer to an array of ISO Latin 1 chars @inlen: the length of @in
Take a block of ISO Latin 1 chars in and try to convert it to an UTF-8 block of chars out. Returns the number of bytes written if success, or -1 otherwise The value of @inlen after return is the number of octets consumed if the return value is positive, else unpredictable. The value of @outlen after return is the number of octets produced.
Definition at line 316 of file encoding.c.
Referenced by xmlInitCharEncodingHandlers().
|
static |
xmlErrEncoding: @error: the error number @msg: the error message
n encoding error
Definition at line 105 of file encoding.c.
|
static |
UTF16BEToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @inb: a pointer to an array of UTF-16 passed as a byte array @inlenb: the length of @in in UTF-16 chars
Take a block of UTF-16 ushorts in and try to convert it to an UTF-8 block of chars out. This function assumes the endian property is the same between the native type of this machine and the inputed one.
Returns the number of bytes written, or -1 if lack of space, or -2 if the transcoding fails (if *in is not a valid utf16 string) The value of *inlen after return is the number of octets consumed if the return value is positive, else unpredictable.
Definition at line 751 of file encoding.c.
Referenced by xmlInitCharEncodingHandlers().
|
static |
UTF16LEToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @inb: a pointer to an array of UTF-16LE passwd as a byte array @inlenb: the length of @in in UTF-16LE chars
Take a block of UTF-16LE ushorts in and try to convert it to an UTF-8 block of chars out. This function assumes the endian property is the same between the native type of this machine and the inputed one.
Returns the number of bytes written, or -1 if lack of space, or -2 if the transcoding fails (if *in is not a valid utf16 string) The value of *inlen after return is the number of octets consumed if the return value is positive, else unpredictable.
Definition at line 508 of file encoding.c.
Referenced by xmlInitCharEncodingHandlers().
|
static |
UTF8ToUTF8: @out: a pointer to an array of bytes to store the result @outlen: the length of @out @inb: a pointer to an array of UTF-8 chars @inlenb: the length of @in in UTF-8 chars
No op copy operation for UTF8 handling.
Returns the number of bytes written, or -1 if lack of space. The value of *inlen after return is the number of octets consumed if the return value is positive, else unpredictable.
Definition at line 364 of file encoding.c.
Referenced by xmlInitCharEncodingHandlers().
Definition at line 1077 of file encoding.c.
Referenced by main().
long xmlByteConsumed | ( | xmlParserCtxtPtr | ctxt | ) |
xmlByteConsumed: @ctxt: an XML parser context
This function provides the current index of the parser relative to the start of the current entity. This function is computed in bytes from the beginning starting at zero and finishing at the size in byte of the file if parsing a file. The function is of constant cost if the input is UTF-8 but can be costly if run on non-UTF-8 input.
Returns the index in bytes from the beginning of the entity or -1 in case the index could not be computed.
Definition at line 2882 of file encoding.c.
int xmlCharEncCloseFunc | ( | xmlCharEncodingHandler * | handler | ) |
xmlCharEncCloseFunc: @handler: char encoding transformation data structure
Generic front-end for encoding handler close function
Returns 0 if success, or -1 in case of error
Definition at line 2796 of file encoding.c.
Referenced by xmlSwitchInputEncodingInt().
int xmlCharEncFirstLine | ( | xmlCharEncodingHandler * | handler, |
xmlBufferPtr | out, | ||
xmlBufferPtr | in | ||
) |
xmlCharEncFirstLine: @handler: char encoding transformation data structure @out: an xmlBuffer for the output. @in: an xmlBuffer for the input
Front-end for the encoding handler input function, but handle only the very first line, i.e. limit itself to 45 chars.
Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or
Definition at line 2160 of file encoding.c.
int xmlCharEncFirstLineInput | ( | xmlParserInputBufferPtr | input, |
int | len | ||
) |
xmlCharEncFirstLineInput: @input: a parser input buffer @len: number of bytes to convert for the first line, or -1
Front-end for the encoding handler input function, but handle only the very first line. Point is that this is based on autodetection of the encoding and once that first line is converted we may find out that a different decoder is needed to process the input.
Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or
Definition at line 2181 of file encoding.c.
Referenced by xmlSwitchInputEncodingInt().
int xmlCharEncFirstLineInt | ( | xmlCharEncodingHandler * | handler, |
xmlBufferPtr | out, | ||
xmlBufferPtr | in, | ||
int | len | ||
) |
xmlCharEncFirstLineInt: @handler: char encoding transformation data structure @out: an xmlBuffer for the output. @in: an xmlBuffer for the input @len: number of bytes to convert for the first line, or -1
Front-end for the encoding handler input function, but handle only the very first line, i.e. limit itself to 45 chars.
Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or
Definition at line 2074 of file encoding.c.
Referenced by xmlCharEncFirstLine().
int xmlCharEncInFunc | ( | xmlCharEncodingHandler * | handler, |
xmlBufferPtr | out, | ||
xmlBufferPtr | in | ||
) |
xmlCharEncInFunc: @handler: char encoding transformation data structure @out: an xmlBuffer for the output. @in: an xmlBuffer for the input
Generic front-end for the encoding handler input function
Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or
Definition at line 2383 of file encoding.c.
int xmlCharEncInput | ( | xmlParserInputBufferPtr | input, |
int | flush | ||
) |
xmlCharEncInput: @input: a parser input buffer @flush: try to flush all the raw buffer
Generic front-end for the encoding handler on parser input
Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or
Definition at line 2288 of file encoding.c.
Referenced by xmlSwitchInputEncodingInt().
int xmlCharEncOutFunc | ( | xmlCharEncodingHandler * | handler, |
xmlBufferPtr | out, | ||
xmlBufferPtr | in | ||
) |
xmlCharEncOutFunc: @handler: char encoding transformation data structure @out: an xmlBuffer for the output. @in: an xmlBuffer for the input
Generic front-end for the encoding handler output function a first call with @in == NULL has to be made firs to initiate the output in case of non-stateless encoding needing to initiate their state or the output (like the BOM in UTF16). In case of UTF8 sequence conversion errors for the given encoder, the content will be automatically remapped to a CharRef sequence.
Returns the number of byte written if success, or -1 general error -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or
Definition at line 2645 of file encoding.c.
xmlCleanupCharEncodingHandlers:
DEPRECATED: This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all.
Cleanup the memory allocated for the char encoding support, it unregisters all the encoding handlers and the aliases.
Definition at line 1483 of file encoding.c.
Referenced by xmlCleanupParser().
xmlCleanupEncodingAliases:
Unregisters all aliases
Definition at line 1012 of file encoding.c.
Referenced by xmlCleanupCharEncodingHandlers().
xmlDelEncodingAlias: @alias: the alias name as parsed, in UTF-8 format (ASCII actually)
Unregisters an encoding alias @alias
Returns 0 in case of success, -1 in case of error
Definition at line 1134 of file encoding.c.
xmlCharEncoding xmlDetectCharEncoding | ( | const unsigned char * | in, |
int | len | ||
) |
xmlDetectCharEncoding: @in: a pointer to the first bytes of the XML entity, must be at least 2 bytes long (at least 4 if encoding is UTF4 variant). @len: pointer to the length of the buffer
Guess the encoding of the entity using the first bytes of the entity content according to the non-normative appendix F of the XML-1.0 recommendation.
Returns one of the XML_CHAR_ENCODING_... values.
Definition at line 952 of file encoding.c.
Referenced by xmlCtxtResetPush(), xmlParseDocument(), xmlParseExternalEntityPrivate(), xmlParseExternalSubset(), xmlParseExtParsedEnt(), xmlParsePEReference(), and xmlSAX2ExternalSubset().
|
static |
xmlEncInputChunk: @handler: encoding handler @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 @flush: flush (ICU-related)
Returns 0 if success, or -1 by lack of space, or -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or -3 if there the last byte can't form a single output char.
The value of @inlen after return is the number of octets consumed as the return value is 0, else unpredictable. The value of @outlen after return is the number of octets produced.
Definition at line 1979 of file encoding.c.
Referenced by xmlCharEncFirstLineInput(), xmlCharEncFirstLineInt(), xmlCharEncInFunc(), and xmlCharEncInput().
xmlEncodingErrMemory: @extra: extra information
Handle an out of memory condition
Definition at line 93 of file encoding.c.
Referenced by xmlInitCharEncodingHandlers(), and xmlNewCharEncodingHandler().
|
static |
xmlEncOutputChunk: @handler: encoding handler @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
Returns 0 if success, or -1 by lack of space, or -2 if the transcoding fails (for *in is not valid utf8 string or the result of transformation can't fit into the encoding we want), or -3 if there the last byte can't form a single output char. -4 if no output function was found.
The value of @inlen after return is the number of octets consumed as the return value is 0, else unpredictable. The value of @outlen after return is the number of octets produced.
Definition at line 2029 of file encoding.c.
Referenced by xmlByteConsumed(), and xmlCharEncOutFunc().
xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler | ( | const char * | name | ) |
Definition at line 1678 of file encoding.c.
Referenced by xmlCtxtResetPush(), xmlDoRead(), xmlFindCharEncodingHandler(), xmlGetCharEncodingHandler(), xmlParseEncodingDecl(), xmlParseInNodeContext(), xsltSaveResultToFd(), xsltSaveResultToFile(), xsltSaveResultToFilename(), and xsltSaveResultToString().
xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler | ( | xmlCharEncoding | enc | ) |
xmlGetCharEncodingHandler: @enc: an xmlCharEncoding value.
Search in the registered set the handler able to read/write that encoding.
Returns the handler or NULL if not found
Definition at line 1544 of file encoding.c.
Referenced by xmlSwitchEncoding().
const char * xmlGetCharEncodingName | ( | xmlCharEncoding | enc | ) |
xmlGetCharEncodingName: @enc: the encoding
The "canonical" name for XML encoding. C.f. http://www.w3.org/TR/REC-xml#charencoding Section 4.3.3 Character Encoding in Entities
Returns the canonical name for the given encoding
Definition at line 1254 of file encoding.c.
Referenced by xmlFindCharEncodingHandler(), xmlSwitchEncoding(), and xsltSaveResultTo().
xmlGetEncodingAlias: @alias: the alias name as parsed, in UTF-8 format (ASCII actually)
Lookup an encoding name for the given alias.
Returns NULL if not found, otherwise the original name
Definition at line 1039 of file encoding.c.
Referenced by xmlFindCharEncodingHandler(), xmlNewCharEncodingHandler(), and xmlParseCharEncoding().
xmlInitCharEncodingHandlers:
DEPRECATED: This function will be made private. Call xmlInitParser to initialize the library.
Initialize the char encoding support, it registers the default encoding supported. NOTE: while public, this function usually doesn't need to be called in normal processing.
Definition at line 1420 of file encoding.c.
Referenced by xmlFindCharEncodingHandler(), xmlGetCharEncodingHandler(), xmlInitParser(), and xmlRegisterCharEncodingHandler().
xmlCharEncodingHandlerPtr xmlNewCharEncodingHandler | ( | const char * | name, |
xmlCharEncodingInputFunc | input, | ||
xmlCharEncodingOutputFunc | output | ||
) |
Definition at line 1338 of file encoding.c.
Referenced by xmlInitCharEncodingHandlers().
xmlCharEncoding xmlParseCharEncoding | ( | const char * | name | ) |
Definition at line 1170 of file encoding.c.
Referenced by xmlFindCharEncodingHandler().
void xmlRegisterCharEncodingHandler | ( | xmlCharEncodingHandlerPtr | handler | ) |
xmlRegisterCharEncodingHandler: @handler: the xmlCharEncodingHandlerPtr handler block
Register the char encoding handler, surprising, isn't it ?
Definition at line 1509 of file encoding.c.
Referenced by xmlNewCharEncodingHandler().
|
static |
Definition at line 1317 of file encoding.c.
Referenced by compile_state_table(), find_sink_entry(), notify_DllMain(), notify_TlsCallback(), xmlCharEncCloseFunc(), xmlCleanupCharEncodingHandlers(), xmlFindCharEncodingHandler(), xmlGetCharEncodingHandler(), xmlInitCharEncodingHandlers(), and xmlRegisterCharEncodingHandler().
|
static |
Definition at line 1318 of file encoding.c.
Referenced by xmlCharEncCloseFunc(), xmlCleanupCharEncodingHandlers(), xmlFindCharEncodingHandler(), and xmlRegisterCharEncodingHandler().
|
static |
Definition at line 70 of file encoding.c.
Referenced by xmlAddEncodingAlias(), xmlCleanupEncodingAliases(), xmlDelEncodingAlias(), and xmlGetEncodingAlias().
|
static |
Definition at line 72 of file encoding.c.
Referenced by xmlAddEncodingAlias(), and xmlCleanupEncodingAliases().
|
static |
Definition at line 71 of file encoding.c.
Referenced by xmlAddEncodingAlias(), xmlCleanupEncodingAliases(), xmlDelEncodingAlias(), and xmlGetEncodingAlias().
|
static |
Definition at line 1325 of file encoding.c.
Referenced by xmlCleanupCharEncodingHandlers(), and xmlFindCharEncodingHandler().
|
static |
Definition at line 84 of file encoding.c.
Referenced by UTF16BEToUTF8(), UTF16LEToUTF8(), and xmlInitCharEncodingHandlers().
|
static |
Definition at line 61 of file encoding.c.
Referenced by xmlGetCharEncodingHandler(), and xmlInitCharEncodingHandlers().
|
static |
Definition at line 60 of file encoding.c.
Referenced by xmlGetCharEncodingHandler(), and xmlInitCharEncodingHandlers().