You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Hugo Duncan <hu...@ALCAN.COM> on 2000/05/19 14:06:41 UTC
Problem with escaping of characters output by XMLFormatter
XMLFormatter seems to miss characters that need escaping when they are not
at the beginning of the output string (eg ampersand when using stdEscape).
This seems to fix things for me:
Index: src/util/XMLUTF8Transcoder.cpp
===================================================================
RCS file: /home/cvspublic/xml-xerces/c/src/util/XMLUTF8Transcoder.cpp,v
retrieving revision 1.7
diff -r1.7 XMLUTF8Transcoder.cpp
287c287
< while (true)
---
> while (srcPtr<srcEnd)
Re: Problem with escaping of characters output by XMLFormatter
Posted by Rahul Jain <ra...@jtcsv.com>.
finished checking this fix into the source code base.
rahul
Re: Problem with escaping of characters output by XMLFormatter
Posted by Dean Roddey <dr...@charmedquark.com>.
Yes, I think that's correct. I did all of the intrinsic transcoders at once,
and obviously was going a bit too fast. The next check, for a null, is also
probably not right. This particular method is not null terminated string
based, its buffer based and the caller is expected to tell us the right
amount of source.
So, early in the formatTo() method, it should look like this:
const XMLCh* srcPtr = srcData;
const XMLCh* srcEnd = srcPtr + srcCount;
XMLByte* outPtr = toFill;
XMLByte* outEnd = toFill + maxBytes;
while (srcPtr < srcEnd)
{
//
// Tentatively get the next char out. We have to get it into a
// 32 bit value, because it could be a surrogate pair.
//
XMLUInt32 curVal = *srcPtr;
//
// If its a leading surrogate, then lets see if we have the
trailing
// available. If not, then give up now and leave it for next time.
//
unsigned int srcUsed = 1;
That should do it I think.
--------------------------
Dean Roddey
The CIDLib Class Libraries
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com
"Give me immortality, or give me death"
----- Original Message -----
> XMLFormatter seems to miss characters that need escaping when they are not
> at the beginning of the output string (eg ampersand when using stdEscape).
> This seems to fix things for me:
>
> Index: src/util/XMLUTF8Transcoder.cpp
> ===================================================================
> RCS file: /home/cvspublic/xml-xerces/c/src/util/XMLUTF8Transcoder.cpp,v
> retrieving revision 1.7
> diff -r1.7 XMLUTF8Transcoder.cpp
> 287c287
> < while (true)
> ---
> > while (srcPtr<srcEnd)
>