1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-01 00:58:16 +03:00

fixing bug #103100 with a dummy UTF8ToUTF8 copy Daniel

* encoding.c: fixing bug #103100 with a dummy UTF8ToUTF8 copy
Daniel
This commit is contained in:
Daniel Veillard 2003-01-14 13:42:37 +00:00
parent e6227e0549
commit 81601f9834
2 changed files with 42 additions and 1 deletions

View File

@ -1,3 +1,7 @@
Tue Jan 14 14:41:18 CET 2003 Daniel Veillard <daniel@veillard.com>
* encoding.c: fixing bug #103100 with a dummy UTF8ToUTF8 copy
Tue Jan 14 12:40:29 CET 2003 Daniel Veillard <daniel@veillard.com>
* python/generator.py python/libxml.c python/libxml.py

View File

@ -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 =