Hi,
I have a sample XML file with data of Entity reference of Ç (file
content as below)
************************
<?xml version="1.0" encoding="utf-8"?>
<Text>Ç</Text>
************************
Below is the portion of code that creates a UTF-8 encoder, reads the data
and converts it to char* for further processing. 

if (domNodeX->getNodeType() == DOMNode::TEXT_NODE)
   {
                
        XMLTranscoder* utf8Transcoder ;
        XMLTransService::Codes failReason;
        utf8Transcoder =
                XMLPlatformUtils::fgTransService->makeNewTranscoderFor("UTF-8",
failReason, 16*1024);

        XMLCh *ptrXMLChText = (XMLCh *) domNodeX->getNodeValue();
        unsigned long ulLength = XMLString::stringLen(ptrXMLChText);
        long uiOutLength  =  ulLength * 4;
        XMLByte* utf8ByteString = (XMLByte*)malloc(uiOutLength + 1);
        memset(utf8ByteString, 0, uiOutLength + 1);
        unsigned int eaten;

        unsigned int xmlCharsLength =
utf8Transcoder->transcodeTo(ptrXMLChText, ulLength, utf8ByteString, 
uiOutLength, eaten, XMLTranscoder::UnRep_Throw);
        utf8ByteString[xmlCharsLength] = '\0';
        strTempPara = (char *)utf8ByteString;

        for(nIterator = 0; nIterator < xmlCharsLength;  nIterator++)
        {
           ucTempPara = *strTempPara;
           printf("[%c]-[%d]\n", ucTempPara,ucTempPara);    //Prints WRONG ASCII
VALUE
           strTempPara++;
        }
        free(utf8Transcoder);   
    }

My problem is that although the Input file data ASCII value is 199, the
value that get printed from my code is 195... any ideas as to what am i
doing wrong.

PS: the above is just a sample file, i use UTF8 transcoder to retrieve data
since the data range can be out of USASCII range
-- 
View this message in context: 
http://old.nabble.com/UTF-8-transcodeTo-doesnt-return-correct-Ascii-value%2C-what-am-i-doing-wrong-tp28540627p28540627.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to