QString encoding problem
-
Hi,
I have a code in Qt5 which looks like this:-QString str("âáéì");
Whenever I am converting it to C++ std::string using toStdString(), Its giving me invalid characters. I have tried all encoding and its not working at all. I have my Qt built with ICU libs. Please help me in this regard.
BTW if i print QString using qDebug() its printing ????
-
@sonulohani
What version of Qt5? -
@sonulohani
the problem is when you insert it this way the default encoding from the compiler/file is taken. Which is most probably not what you want for special characters.Use the unicode escaping syntax to ensure the correct character data. e.g. "\uf02a" or whatever.
@sonulohani said in QString encoding problem:
Whenever I am converting it to C++ std::string using toStdString(), Its giving me invalid characters.
how do you excactly check for those "invalid" characters?
-
@raven-worx Hi, thanks for the answer. And if i get \u**** output, how do i convert it into the character.
-
@sonulohani said in QString encoding problem:
how do i convert it into the character.
what do you mean?
A "character" is just data. It just matters if you interpret it as a (Unicode-)character.
Thats why i asked how you exactly check for those "invalid" characters?