I have some problems with reading UTF-8 encoded text from file. My version reads only ASCII characters.
#include <QtCore>
int main()
{
QFile file("s.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
return -1;
}
QTextStream in(&file);
while(!in.atEnd())
{
QString line = in.readLine();
qDebug() << line;
}
}
s.txt:
jąkać się
ślimak
śnieżyca
output:
"jka si"
"limak"
"nieyca"
What should I use?
in.setCodec("UTF-8");