Symbian mobile app - wrong charset - encoding
-
Hello,
!http://alergiaapp.madnes.eu/alergiaapp.jpg(app)!I developing mobile application in slovak language. I have everywere set encoding UTF-8. But slovak special characters are wrong on mobile. See the picture. Thanks for help.
-
Have You tried playing with QTextCodec??
QTextCodec::setCodecForCStrings() or void QTextCodec::setCodecForLocale ( QTextCodec * c )
-
No i dont. How / WHERE i can use this ? Thank you
-
@int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForCStrings(codec);
QTextCodec::setCodecForLocale(codec);
........
return app.exec();
}@ -
Thanks. Its ok in simulator but in mobile dont show some characters like žščľ... I have Sony Ericsson vivaz Symbian S60 5th edition
-
Try changing encoding for the source files... "Tools->Options->Environment". Try changing "Default file encoding" to UTF-8 and see if it fixes the issue, it did for me for Swedish characters
-
You can use the following code snippet for a specific string.
@QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QString encodedString = codec->toUnicode(yourString);@The encodedString should then be in the correct encoding.
-
Actually the text encoding should match with the encoding used by the files that hold the text you want to read (e.g. your source files). If your editor stores the strings in non-utf8 and you instruct Qt to load the strings assuming it will be utf8 then this will not work correctly.
-
Hi
I had the same problem with german Umlaute. If reply is your QNetworkReply, it should work with the following code snippet.@QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QString encodedString = codec->toUnicode(reply->readAll());@ -
lukiluuk: If you know you are getting Utf8 then you can use QString::fromUtf8(). There is also some conversion routine for ASCII and Latin1 (both of which are straight forward to turn into unicode and thus do not need the full TextCodec treatment:-).