'Are accents and special characters broken in Qt6?

I've got a Qt program that reads from csv files and saves the info into a database. There was no problem until i tried to update from Qt 5.15.2 to Qt 6.3. Now, when I read from the files, all accents are converted to a question mark.

I've tried using pretty much every way to explicitly interpret a QTextStream or convert a QString text to Utf-8 or Unicode in general and they all failed to work. Is this a known issue in Qt 6 (because accents worked perfectly in Qt 5.15.2)?

Thanks in advance.

As requested here's the fragment that reads the csv files:

QFile file(path);
file.open(QIODevice::ReadOnly | QIODevice::Text);

QTextStream in(&file);
while (in.readLineInto(&line)){
   QStringList separatedLine = line.split("\t");
   qDebug() << separatedLine;
   //do things and save data in database
}

The issue I have is that this works perfectly if I compile it with Qt5.15.2 but not in Qt6.3.0. Reading the exact same .csv file the following is debbuged:

//Original line
34111514 TARJETA COMUNICACIÓN TMB-251 TMB251

//Qt 5.15.2 qDebug outputs
QList("34111514", "TARJETA COMUNICACIÓN TMB-251", "TMB251")

//Qt 6.3 qDebug outputs
QList("34111514", "TARJETA COMUNICACI?N TMB-251", "TMB251")

I highly doubt it's a problem with the csv file formatting because it works fine in older Qt.



Solution 1:[1]

Okay so after a couple more days of research and trying things it now works. I cannot reproduce the issue but something must have had happened when I used LibreOffice Calc to save the csv encoded as UTF-8 or when I sent that file by email. I suppose the encoding might have gotten in some way changed or corrupted into something that, for some reason, Qt5.15.2 could interpret but Qt6.3 couldn't. I fixed the issue by using Notepad++ to encode the file as UTF-8 again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheWookieDavid