From fdad370c5b718bcf1aad9478d3c4c68c00498219 Mon Sep 17 00:00:00 2001 From: James Clark Date: Mon, 2 Feb 1998 11:14:46 +0000 Subject: [PATCH] Fix bug with UTF16 to UTF8 conversion for chars 0x80..0xFF --- expat/xmltok/xmltok.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/expat/xmltok/xmltok.c b/expat/xmltok/xmltok.c index cbca6b18..7bcfb0c7 100755 --- a/expat/xmltok/xmltok.c +++ b/expat/xmltok/xmltok.c @@ -256,12 +256,15 @@ void PREFIX(toUtf8)(const ENCODING *enc, \ unsigned char hi = GET_HI(from); \ switch (hi) { \ case 0: \ - if (*toP == toLim) { \ - *fromP = from; \ - return; \ + if (lo < 0x80) { \ + if (*toP == toLim) { \ + *fromP = from; \ + return; \ + } \ + *(*toP)++ = lo; \ + break; \ } \ - *(*toP)++ = lo; \ - break; \ + /* fall through */ \ case 0x1: case 0x2: case 0x3: \ case 0x4: case 0x5: case 0x6: case 0x7: \ if (toLim - *toP < 2) { \