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?

see qtextstream::setcodec():

in.setcodec("utf-8"); 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -