Utf-8 coding problem



  • QMessageBox::information(this,"","ł"); is greeting me with ł character.
    The same problem exists in table headers and other places. I've solved it there by using deprecated trUtf8() function.

    What is wrong? How to deal with that?


  • Moderators

    Which compiler are you using? Is your source file encoded using UTF-8?



  • @sierdzio
    Qt Creator 2.8.1
    Qt 4.8.6
    GCC 4.8.4, 64 bit

    user@linux$ file *.cpp LabWareHouse.pro
    database.cpp:                             C source, ASCII text
    databaseinfo.cpp:                         C source, ASCII text
    databasemanager.cpp:                      C source, UTF-8 Unicode text
    dialog_bladsql.cpp:                       C source, ASCII text
    dialog_dodajpojemnik.cpp:                 C source, UTF-8 Unicode text
    dialog_dodajprzestrzenmagazynowa.cpp:     C source, ASCII text
    dialog_dodajsubstancje.cpp:               C source, UTF-8 Unicode text
    dialog_generujraport.cpp:                 C source, ASCII text
    dialog_historiapojemnika.cpp:             C source, ASCII text
    dialog_odzyskajpliki.cpp:                 C source, UTF-8 Unicode text
    dialog_oprogramie.cpp:                    C source, ASCII text
    dialog_updateprogram.cpp:                 C source, ASCII text
    dialog_zmianastanupojemnika.cpp:          C source, ASCII text
    ikonazapisu.cpp:                          C source, ASCII text
    main.cpp:                                 C source, ASCII text
    mainwindow.cpp:                           C source, UTF-8 Unicode text
    moc_databasemanager.cpp:                  C source, ASCII text
    moc_dialog_bladsql.cpp:                   C source, ASCII text
    moc_dialog_databasewizard.cpp:            C source, ASCII text
    moc_dialog_dodajpojemnik.cpp:             C source, ASCII text
    moc_dialog_dodajprzestrzenmagazynowa.cpp: C source, ASCII text
    moc_dialog_dodajsubstancje.cpp:           C source, ASCII text
    moc_dialog_generujraport.cpp:             C source, ASCII text
    moc_dialog_historiapojemnika.cpp:         C source, ASCII text
    moc_dialog_oprogramie.cpp:                C source, ASCII text
    moc_dialog_zmianastanupojemnika.cpp:      C source, ASCII text
    moc_mainwindow.cpp:                       C source, ASCII text
    modelmanager.cpp:                         C source, UTF-8 Unicode text
    qrc_resources.cpp:                        Qt C-code resource file, ASCII text
    utils.cpp:                                C source, ASCII text
    LabWareHouse.pro:                         ASCII text
    

    mainwindow.cpp which contains this unlucky string is UTF-8 encoded



  • If I'm not completely mistaken Qt 4.8 does not assume c-strings to be in UTF-8 by default,
    but instead assumes they are in the systems default encoding. Have you tried with:
    QString::fromUtf8("mystring");?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.