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 bu...@apache.org on 2002/04/09 12:15:28 UTC
DO NOT REPLY [Bug 7859] New: -
XMLString::transcode added garbage characters
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7859>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7859
XMLString::transcode added garbage characters
Summary: XMLString::transcode added garbage characters
Product: Xerces-C++
Version: 1.6.0
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: Utilities
AssignedTo: xerces-c-dev@xml.apache.org
ReportedBy: hogura@jp.ibm.com
I found the bug on Xerces 1.6.0, but I had not found on XML4C 2.4.3.
When XMLString transcode a text that includes entity reference: "<", ">"
using XMLString::transcode() method, then the method add garbage characters to
original characters.
Sample code is following:
#include <util/PlatformUtils.hpp>
#include <framework/MemBufInputSource.hpp>
#include <util/TranscodingException.hpp>
#include <dom/DOM_DOMException.hpp>
#include <parsers/DOMParser.hpp>
#include <dom/DOM.hpp>
#include <string.h>
#include <iostream>
// The text includes entity reference: "<", ">".
char* srcStr = "<text><aaaaa>aaa</text>";
int main(int argc, char* argv[])
{
XMLPlatformUtils::Initialize();
DOMParser parser;
parser.setDoValidation(false);
MemBufInputSource* memBufIS = new MemBufInputSource((const XMLByte*)
srcStr, strlen(srcStr), "test");
parser.parse(*memBufIS);
DOM_Node node = parser.getDocument().getDocumentElement();
DOM_Node child = node.getFirstChild();
DOMString domStr = child.getNodeValue();
// DOMString::transcode : success
char* dch = domStr.transcode();
std::cout << dch << std::endl;
// XMLString::transcode : error!!!!!!!!!! added garbage characters
char* ch = XMLString::transcode(domStr.rawBuffer());
std::cout << ch << std::endl;
XMLPlatformUtils::Terminate();
return 0;
}
Output result:
<aaaaa>aaa
<aaaaa>aaa��������
Best regards,
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org