neilg 2003/10/09 19:06:09 Modified: c/src/xercesc/framework XMLFormatter.cpp XMLFormatter.hpp Log: fix for bug 21780; thanks to David Cargill Revision Changes Path 1.16 +35 -2 xml-xerces/c/src/xercesc/framework/XMLFormatter.cpp Index: XMLFormatter.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLFormatter.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- XMLFormatter.cpp 8 Sep 2003 21:48:36 -0000 1.15 +++ XMLFormatter.cpp 10 Oct 2003 02:06:09 -0000 1.16 @@ -537,6 +537,28 @@ } +void XMLFormatter::writeCharRef(unsigned long toWrite) +{ + XMLCh tmpBuf[32]; + tmpBuf[0] = chAmpersand; + tmpBuf[1] = chPound; + tmpBuf[2] = chLatin_x; + + // Build a char ref for the current char + XMLString::binToText(toWrite, &tmpBuf[3], 8, 16); + const unsigned int bufLen = XMLString::stringLen(tmpBuf); + tmpBuf[bufLen] = chSemiColon; + tmpBuf[bufLen+1] = chNull; + + // write it out + formatBuf(tmpBuf + , bufLen + 1 + , XMLFormatter::NoEscapes + , XMLFormatter::UnRep_Fail); + +} + + const XMLByte* XMLFormatter::getCharRef(unsigned int & count, XMLByte* &ref, const XMLCh * stdRef) @@ -614,7 +636,18 @@ // while (srcPtr < endPtr) { - writeCharRef(*srcPtr); + if ((*srcPtr & 0xFC00) == 0xD800) { + // we have encountered a surrogate, need to recombine before printing out + // use writeCharRef that takes unsigned long to get values larger than + // hex 0xFFFF printed. + tmpPtr = srcPtr; + tmpPtr++; // point at low surrogate + writeCharRef((unsigned long) (0x10000+((*srcPtr-0xD800)<<10)+*tmpPtr-0xDC00)); + srcPtr++; // advance to low surrogate (will advance again below) + } + else { + writeCharRef(*srcPtr); + } // Move up the source pointer and break out if needed srcPtr++; 1.18 +5 -1 xml-xerces/c/src/xercesc/framework/XMLFormatter.hpp Index: XMLFormatter.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/XMLFormatter.hpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- XMLFormatter.hpp 22 Sep 2003 08:50:04 -0000 1.17 +++ XMLFormatter.hpp 10 Oct 2003 02:06:09 -0000 1.18 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.18 2003/10/10 02:06:09 neilg + * fix for bug 21780; thanks to David Cargill + * * Revision 1.17 2003/09/22 08:50:04 gareth * doc fix * @@ -456,6 +459,7 @@ const XMLCh * stdRef); void writeCharRef(const XMLCh &toWrite); + void writeCharRef(unsigned long toWrite); bool inEscapeList(const XMLFormatter::EscapeFlags escStyle , const XMLCh toCheck);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]