[Qt-interest] Problesm with utf-8 encoded XML and japanesecharacters

Scott Aron Bloom Scott.Bloom at sabgroup.com
Wed Sep 23 09:17:50 CEST 2009


Unfortunately, it looks like the XML attachment got stripped off…

 

Sorry..  Here is the XML

 

<?xml version="1.0" encoding="utf-8"?>

<test>

      <text lang="ja">Quit 日本語</text>

</test>

 

 

 

From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Scott Aron Bloom
Sent: Wednesday, September 23, 2009 12:10 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Problesm with utf-8 encoded XML and japanesecharacters

 

I read in the attached test.xml (which is UTF-8 encoded, and contains Japanese characters)

 

When I load the XML into a proper editor, the Japanese characters are plain as day.

 

However, I need to thread the XML in, so I use QDomDocument

                  QFile inFile( fileName );

                  if ( !inFile.open( QIODevice::ReadOnly ) )

                  {

                        return;

                  }

 

                  QString errorMsg;

                  int line, column;

                  if ( !doc.setContent( &inFile, &errorMsg, &line, &column ) )

                  {

                        return;

                  }

Where filename is the filename of the path… It loads fine, and there are no errors on the setContent.

 

However,

 

When I get the QString for the value in question (for the simplified XML)

 

QString tmp = doc.firstChildElement().firstChildElement().text();

 

The japansese characters have been replaced with the ascii representation of the text, not the unicode.

 

What can I do to avoid this?  What am I doing wrong?

Scott

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090923/bfcd3077/attachment.html 


More information about the Qt-interest-old mailing list