diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2003-01-14 13:42:37 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2003-01-14 13:42:37 +0000 |
commit | 81601f9834667bb47b4b2c9d15b52579ffbe4088 (patch) | |
tree | a3afb5c4875a033be2efa8476e75e8553650f08c /encoding.c | |
parent | e6227e0549490b5bf9271ecd2d874a97c3f4852b (diff) | |
download | libxml2-81601f9834667bb47b4b2c9d15b52579ffbe4088.tar.gz |
fixing bug #103100 with a dummy UTF8ToUTF8 copy Daniel
* encoding.c: fixing bug #103100 with a dummy UTF8ToUTF8 copy
Daniel
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -591,6 +591,43 @@ isolat1ToUTF8(unsigned char* out, int *outlen, return(0); } +/** + * 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 byte written, or -1 by lack of space, or -2 + * if the transcoding fails (for *in is not valid utf16 string) + * The value of *inlen after return is the number of octets consumed + * as the return value is positive, else unpredictable. + */ +static int +UTF8ToUTF8(unsigned char* out, int *outlen, + const unsigned char* inb, int *inlenb) +{ + int len; + + if ((out == NULL) || (inb == NULL) || (outlen == NULL) || (inlenb == NULL)) + return(-1); + if (*outlen > *inlenb) { + len = *inlenb; + } else { + len = *outlen; + } + if (len < 0) + return(-1); + + memcpy(out, inb, len); + + *outlen = len; + *inlenb = len; + return(0); +} + /** * UTF8Toisolat1: @@ -1579,7 +1616,7 @@ xmlInitCharEncodingHandlers(void) { "xmlInitCharEncodingHandlers : out of memory !\n"); return; } - xmlNewCharEncodingHandler("UTF-8", NULL, NULL); + xmlNewCharEncodingHandler("UTF-8", UTF8ToUTF8, UTF8ToUTF8); xmlUTF16LEHandler = xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE); xmlUTF16BEHandler = |