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 2003/07/14 06:48:52 UTC
DO NOT REPLY [Bug 21556] New: -
UTF-8 Data getting corrupted after Parsing
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=21556>.
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=21556
UTF-8 Data getting corrupted after Parsing
Summary: UTF-8 Data getting corrupted after Parsing
Product: Xerces-C++
Version: 2.3.0
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Major
Priority: Other
Component: DOM
AssignedTo: xerces-c-dev@xml.apache.org
ReportedBy: firoz_tm@yahoo.com
Hi,
I got one Japanese XML which is encoded using UTF-8. If I do a string
comparison of File Content before parsing and Data regenerated from the
Parser, I am finding difference at the place where Japanese characters
are inserted. How can I get the same data from the parser back. Or is
there anything I shoulld do inorder to make it working. Can any one help me in
solving this issue.. It will be great if someone can....
Here is the code:
void main(int argc, char* argv[])
{
XMLPlatformUtils::Initialize();
XercesDOMParser *parser = new XercesDOMParser;
char* lpBuf =
ReadFromFile("D:/TEMP/Japanese/BasicConfig_SJIS_All.xml");
if(lpBuf)
{
Parse(lpBuf, parser );
}
delete parser;
}
bool Parse(const char* lpszStr, XercesDOMParser *pParser )
{
char Temp[40] ="";
strcpy(Temp,"GG.Doc.1.XML");
MemBufInputSource m_Source(
(const XMLByte*)lpszStr
, strlen(lpszStr)
, Temp
, false
);
try
{
pParser->parse(m_Source);
}
catch(...)
{
return false;
}
DOMNodeList* pNodes =
pParser->getDocument()->getElementsByTagName(X("*"));
if(!pNodes->getLength())
return false;
DOMNode* n = pNodes->item(0);
CGGString str;
str.SetLineFeed("\r\n");
str << "<?xml version=\"1.0\" encoding=\"shift-jis\"?>" << endl;
str << n;
int Offset=0;
//Routine written for comparing the data, CR/LF will be
//ignored from the comparison.
int iDiff = Compare(lpszStr,str.GetBuffer(),Offset);
return true;
}
Thanking you in advance
-- Firoz
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org