0

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.

2 Answers2

0

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.

Community
  • 1
  • 1
Murphy
  • 3,827
  • 4
  • 21
  • 35
-1

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.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Michał Leon
  • 2,108
  • 1
  • 15
  • 15