Results 1 to 4 of 4

Thread: strange behavious with QMap and non Latin characters

  1. #1
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default strange behavious with QMap and non Latin characters

    I have the following code (map is a QVariantMap):
    Qt Code:
    1. void XmlHandler::addToMap(QString key, QVariant value)
    2. {
    3. qDebug() << "key:" << key << " value:" << value;
    4.  
    5. qDebug() << "before: " << map;
    6. map.insert(key, value);
    7.  
    8. qDebug() << "after: " << map << endl;
    9. }
    To copy to clipboard, switch view to plain text mode 

    Which produces the following output:
    key: "a" value: QVariant(QString, "ab")
    before: QMap()
    after: QMap(("a", QVariant(QString, "ab") ) )

    key: "b" value: QVariant(QString, "ab")
    before: QMap(("a", QVariant(QString, "ab") ) )
    after: QMap(("a", QVariant(QString, "ab") ) ( "b" , QVariant(QString, "ab") ) )
    However... When I use Arabic input, the QMap is courrupted:
    key: "ا" value: QVariant(QString, "او")
    before: QMap()
    after: QMap(("ا", QVariant(QString, "او") ) )

    key: "و" value: QVariant(QString, "او")
    before: QMap(("ا", QVariant(QString, "او") ) )
    after: QMap(("ا", QVariant(QString, "او") ) ( "و" , QVariant(QString, "او") ) )
    You can see that the keys and values have been mixed after the second insert!

    I assumed I was making a mistake somewhere, but I sure don't see one. Can someone suggest what might be going wrong?

    Thanks, B

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: strange behavious with QMap and non Latin characters

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: strange behavious with QMap and non Latin characters

    I've solved the "problem". It is actually just the representation in Qt of right-to-left alphabets when there are "(" and ")" characters. It appears to be corrupt data but this is only the way that Qt is displaying the text.
    QMap(("ا", QVariant(QString, "او") ) ( "و" , QVariant(QString, "او") ) )
    actually is:
    QMap(("ا", QVariant(QString, "او") ))
    QMap(("و", QVariant(QString, "او") ))
    (if you put in a line break)

  4. #4
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: strange behavious with QMap and non Latin characters

    It is just unlucky that QMap's output exactly reverses Arabic text to look like the elements have been corrupted internally!

    Is there a way of marking threads as solved?

Similar Threads

  1. Font family for non-latin text.
    By chandan in forum Newbie
    Replies: 0
    Last Post: 25th May 2010, 13:01
  2. dynamicCall and QByteArray - strange characters
    By franco.amato in forum Qt Programming
    Replies: 120
    Last Post: 28th April 2010, 21:11
  3. QDomElement latin characters
    By jano_alex_es in forum General Programming
    Replies: 2
    Last Post: 21st January 2010, 15:28
  4. Qt and Serbian Latin alphabet
    By frenk_castle in forum Newbie
    Replies: 3
    Last Post: 15th December 2009, 22:34
  5. A strange set of characters appearing
    By bruccutler in forum Qt Programming
    Replies: 7
    Last Post: 19th April 2007, 16:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.