Reputation: 13
i'm trying to convert some data get from a txt file coded in utf16 to utf8 by using Qt. Could someone help in this? Thank you in advance.
Upvotes: 0
Views: 2365
Reputation: 2316
This is the answer: https://doc.qt.io/qt-6/qstringconverter.html
The QStringConverter class is a base class for the QStringEncoder and QStringDecoder classes that help with converting between different text encodings. QStringDecoder can decode a string from an encoded representation into UTF-16, the format Qt uses internally. QStringEncoder does the opposite operation, encoding UTF-16 encoded data (usually in the form of a QString) to the requested encoding.
Upvotes: -1
Reputation: 3999
QString
provides methods to import from UTF-16 and export to UTF-8, and vice versa of course, and many others. The QByteArray
objects used for input/output of these methods are best handled by using QFile
.
You should be able to find your way from there; if you have other problems with using this facilities you're supposed to provide a Minimal, Complete, and Verifiable example in order to get appropriate help.
Upvotes: 0