0

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.