I need convert a QString
to an std::string
. However, if this string contains unicode symbols, I get ????
. How can I convert the string with the proper encoding?
Thank you.
How did you try to convert the string so far?
According to documentation std::string QString::toStdString ()
should convert the unicode-data to an ascii-string
But be warned that you loose special-chars which ascii can't handle.
According to Qt documentation, QString::toStdString internally uses toAscii() function: http://doc.qt.nokia.com/latest/qstring.html#toStdString
Basically, you'll need to make your own converter function that would use QString::toUtf8() instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.