Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Weird Unicode problem with Qt 5.15.0 and MSVC 2019...



  • I've started using MSVC to build my project, It does everything very well, but I have found an error that I'm not sure whats the cause. In the program 95% of the places where Unicode characters are used, they display correctly, but the same words and characters in other places are not, showing the ? sign.
    I've noticed that it happens where I put a string without assigning it to a QString, like this:

    ui->comboGenero->addItem("Fêmea", 0);
    

    The same code like this, works normally:

    ui->comboGenero->addItem(QString("Fêmea"), 0);
    


  • Hi, in MSVC 2019's Tools, Options, Text Editor, General settings, do you have the checkbox "Auto-detect UTF-8 encoding without signature" enabled? Try disabling it.
    Also check that your .cpp file does not have a BOM (byte order mark) at the beginning (if you open the .cpp file with a binary hex editor the first bytes are FF FE something)



  • Thank you so much for the fast and assertive answer.
    Inside Options > Text Editor > Behavior > File Encodings, the UTF-8 BOM option was set to "Keep If already Present", changed it to "Always Delete" and problem solved.


Log in to reply