c++ - How to read UTF-8 text from file using Qt? -
i have problems reading utf-8 encoded text file. version reads 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 use?
in.setcodec("utf-8");
Comments
Post a Comment