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 "Mannion, Enda" <en...@hp.com> on 2006/08/11 16:55:40 UTC

Reading UNICODE character

Hi,

 

 

I am reading a tag called XX from an XML file, this code works ok when XX is and ASCII character but when it is a UNICODE char like € I get problems.

 

Nothing is returned just an empty string, when reading the UNICODE character. I can write the UNICODE character to the XML file without any problems but there is an issue with reading.

 

 

if(node->getFirstChild() != NULL)   

{

XMLCh* n = node->getFirstChild()->getNodeValue();

      char* xmlval = XMLString::transcode(n);           // this line returns “”, empty string??

      m_deviceName = string(xmlval);

      xercesc::XMLString::release(&xmlval);

}

Can anyone suggest a solution,

Thanks,

Enda 

 


Re: Reading UNICODE character

Posted by David Bertoni <db...@apache.org>.
Mannion, Enda wrote:
> Hi,
> 
> I am reading a tag called XX from an XML file, this code works ok when 
> XX is and ASCII character but when it is a UNICODE char like € I get 
> problems.

First of all, I'd like to suggest you direct questions about _using_ 
Xerces-C to the Xerces-C user list, rather than the developer list.

> 
> Nothing is returned just an empty string, when reading the UNICODE 
> character. I can write the UNICODE character to the XML file without any 
> problems but there is an issue with reading.

Axel explained this to you yesterday.  You cannot guarantee that every 
Unicode character can be represented in your system's local code page.  If 
it cannot, then using XMLString::transcode() will fail, and you will end up 
with an empty string.

Since you haven't told us why you're transcoding from UTF-16 to the local 
code page, it's difficult for anyone to offer you useful suggestions. 
Yesterday, I commented that you might want to try UTF-8, instead of the 
local code page, but that may or may not be helpful, depending on your needs.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org