I just want to write some few simple lines to a text file in C++, but I want them to be encoded in UTF-8. What is the easiest and simple way to do so?
std::wstring text = L"Привет"; QString qstr = QString::fromStdWString(text); QByteArray byteArray(qstr.toUtf8()); std::string str_std( byteArray.constData(), byteArray.length());