2

I'm having some troubles converting a string Bob Rosén to Bob Rosén

Tried:

QString str = v.toObject().value("name").toString(); // Contains Bob Rosén
qDebug() << str.toUtf8(); // Outputs Bob Rosén

Any ideas?

1
  • utf8 accents are composed of 2 characters (or more not sure), so when using "toutf8" with qdebug() it will show the REAL characters Commented Apr 19, 2014 at 20:21

1 Answer 1

6

Following works for me. A more elegant solution may exist.

QString str = "Bob Rosén";
qDebug() << QString::fromUtf8(str.toLatin1().constData());
Sign up to request clarification or add additional context in comments.

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.