unable to decode utf-8 characters
Hi, I am trying to read data from text file which is in German language and writing data to sqlite, on desktop everything is working as expected, but on android it is displaying unknown characters (eg: nyomvonal elt�rS impulzusok) .
QString sLine; char *pStr = ( char *)strInput.c_str(); QByteArray encodedString = pStr; nStr = QString::fromUtf8(encodedString); if(nStr.toUtf8() != encodedString) nStr = QString::fromLatin1(encodedString);
qDebug() << "nStr" << nStr ;
Above debug is printing correct text on desktop on android it is not. Any solution highly appreciate.
Hi! Don't know if this is the cause of the problem, but "nyomvonal elt�rS impulzusok" isn't German, but Hungarian I'd guess.
@Pradeep-Reddy Is the string show correctly in the app? This could be just an encoding problem with the terminal.
@jsulm basically i observed the difference
on Desktop QString::fromUtf8(encodedString) is returning proper text.
but on Android QString::fromUtf8(encodedString) it is returning unknown characters...
You should check if your char-array actually contains the correct UTF chars or not.
That said, why do you use std for reading a textfile if your application after that runs in/with Qts own libaries?
@J.Hilk hi .. i am sure the char array is having utf-8 data ..
i am usinf std file stream because if files are with big size .. seeking is not working perfectly if i used with Qfile and QTextStream .