×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    31

    QDomElement fetch text encoding problems

    Hello,

    I am trying to get a french text from an xml here is the part of my code with the problem:

    if (e.attribute("name","")==signName) return e.attribute(att,"");

    The thing is that it doesnt return the french characters instead of them i have a "?". I create the xml from the code too, with QFile, i tried to change the extension from xml to txt no luck, opening the file in notepad or other programs shows the text correctly.Tried to fetch a french text from QFile with the read() method and it also works correcly, tried to put something like this e.attribute().toUTF8 and instead of "?" i get other strange simbols.Is this a problem with dom or the attribute method?

    Thanks,
    ZeroSum

  2. #2
    Registered User
    Join Date
    Dec 2010
    Posts
    31

    XML UTF-8 Trouble

    Hello,

    So created via QDomDocument an xml in which i put a french text, all was well, opened the file with notepad, the french letters were shown correctly, however when i try to fetch the data with QDomElement e.attribute("info","") the format is broken, all the instead of all the french characters i get a "?",tried to make the xml document saved in .txt format still the same problem.If anyone has any suggestions i'd appreciate it.

    Thanks,
    ZeroSum

  3. #3
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QDomElement fetch text encoding problems

    You should specify proper encoding in the opening tag
    Code:
    <?xml version="1.1" encoding="UTF-8"?>

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Location
    Finland
    Posts
    327

    Re: XML UTF-8 Trouble

    Quote Originally Posted by Zerosum3 View Post
    So created via QDomDocument an xml in which i put a french text, all was well, opened the file with notepad, the french letters were shown correctly, however when i try to fetch the data with QDomElement e.attribute("info","") the format is broken, all the instead of all the french characters i get a "?",tried to make the xml document saved in .txt format still the same problem.If anyone has any suggestions i'd appreciate it.
    You have to specify the encoding in the XML - QDomDocument cannot know up-front what encoding your externally inserted text will be in. Daniil has provided you with an example how to specify utf-8 (which is probably what you should use) but if your French text is 8859-1 or something similar, then of course specify that. The fact that a file shows 'correctly' in notepad means little - it's more about the defaults of notepad (and thus your system) than the correctness of encoding in general.

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    31

    Re: XML UTF-8 Trouble

    Hello thank you all for answering,

    I have solved this problem by adding this to my xml:

    <?xml version="1.1" encoding="ISO 8859-1"?>


    Thank you all,
    Zerosum
    Last edited by Zerosum3; 2011-01-12 at 17:13. Reason: UPDATE

  6. #6
    Registered User
    Join Date
    Nov 2012
    Posts
    1

    Re: XML UTF-8 Trouble

    Quote Originally Posted by Zerosum3 View Post
    <?xml version="1.1" encoding="ISO 8859-1"?>
    That helped me a lot. No. It saved me !

Similar Threads

  1. Fetch the global text values
    By prathi in forum Symbian C++
    Replies: 3
    Last Post: 2010-08-11, 17:33
  2. Fetch the text of sms editor
    By hitonly2008 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-12-17, 16:01
  3. how to fetch the displayed text on the mobile handset????
    By PopAndDestroy in forum Symbian C++
    Replies: 9
    Last Post: 2007-03-29, 11:17
  4. to fetch text file
    By sagars in forum Python
    Replies: 11
    Last Post: 2007-03-09, 12:54
  5. to fetch text file
    By sagars in forum Python
    Replies: 0
    Last Post: 2007-02-20, 12:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •