Results 1 to 5 of 5

Thread: utf8 Problem (even in examples)

  1. #1
    Join Date
    Dec 2007
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default utf8 Problem (even in examples)

    I have my system defined to use UTF-8 (standard from the last 2 years), and I am using Mandriva 2007 and/or Mandriva 2008 with qt3 and qt4 both with the same result.

    Basically, if I use the examples included in qt-examples package, and the hello world (simple), changing the "hello world" string for "ção world" or something that have ^;~;';` (needed by my language) it displays strange caracters.

    Extract of the main.cpp provided with qt: (I only changed the "hello" with "ção")
    The file was edit with vim using set fileencoding=utf8
    Also edit with kedit to check if all was ok
    ....
    if ( s.isEmpty() )
    s = "ção, World";
    Hello h( s );
    ....

    If I check using locale, everthing appears to be ok:

    LANG=pt_PT.UTF-8
    LC_CTYPE=pt_PT.UTF-8
    LC_NUMERIC=pt_PT.UTF-8
    LC_TIME=pt_PT.UTF-8
    LC_COLLATE=pt_PT.UTF-8
    LC_MONETARY=pt_PT.UTF-8
    LC_MESSAGES=pt_PT.UTF-8
    LC_PAPER=pt_PT.UTF-8
    LC_NAME=pt_PT.UTF-8
    LC_ADDRESS=pt_PT.UTF-8
    LC_TELEPHONE=pt_PT.UTF-8
    LC_MEASUREMENT=pt_PT.UTF-8
    LC_IDENTIFICATION=pt_PT.UTF-8
    LC_ALL=

    This is not a bug, but a miss configuration somewere. I have tryed my best, but I do not know what can I change.

    I had a personal application in a old system running very well, now that I installed a new system, I am in trouble to make it work fine.

    Thank you

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

    Default Re: utf8 Problem (even in examples)

    Try:
    Qt Code:
    1. if ( s.isEmpty() )
    2. s = QString::fromUtf8("ção, World");
    3. Hello h( s );
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: utf8 Problem (even in examples)


  4. #4
    Join Date
    Dec 2007
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: utf8 Problem (even in examples)

    Thank you both !
    Problem solved.

  5. #5
    Join Date
    Dec 2007
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: utf8 Problem (even in examples)

    For those interested in the same problem, simply changing:

    Qt Code:
    1. s = "ção, World";
    To copy to clipboard, switch view to plain text mode 

    for
    Qt Code:
    1. s = QString("ção, World");
    To copy to clipboard, switch view to plain text mode 

    managed the problem.
    zamotf

Similar Threads

  1. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.