QTextCodec in its current form does not exist in Qt6 (actually it exists, but as part of the qt5compat module).
As a replacement Qt6 has QStringConverter: https://doc-snapshots.qt.io/qt6-dev/qstringconverter.html
The good news is that stuff like textstream.setCodec(QTextCodec::codecForName("UTF-8")); is no longer needed in Qt6 since QTextStream defaults to utf-8.
The bad news is that QStringConverter does not support most of the codecs that QTextCodec supports. It only supports only UTF-8/16/32 and Latin1. See https://bugreports.qt.io/browse/QTBUG-75665 for context. I some places, e.g. Kate we allow the user to choose from a wide range of codecs. https://bugreports.qt.io/browse/QTBUG-86437 indicates that support for other codecs may come back in a future Qt6 release in some form.
There seems to be no equivalent of QTextCodec::codecForLocale in Qt6
QTextCodec is part of the API of KCharSets, which offers additional API around it, e.g. resolving alternative names. Other than that it's not used in public frameworks API, but used internally quite a bit.
Sonnet makes use of QTextCodec internally:
- One usage is removed by https://invent.kde.org/frameworks/sonnet/-/merge_requests/18.
- The hunspell plugin uses it to convert from QString to the dict's encoding. All dicts on my system seem to be either UTF-8 or ISO8859-1 (ag -G "\.aff$" "^SET"), if we can assume that QString or QStringConverter API should be enough. It also uses QTextCodec::codecForLocale() as a fallback if the speller's encoding is not found
- The hspell plugin requires iso8859-8-i, that is not covered by QStringConverter.
KTextEditor uses QTextCodec. Kate should be able to open and save files with all kinds of encodings.
KIO uses QTextCodec internally:
- The http slave uses it for parsing the Content-Disposition header which can have a filename with a supplied encoding
- The http slave uses it for a very questionable workaround: https://invent.kde.org/frameworks/kio/-/blob/master/src/ioslaves/http/httpauthentication.cpp#L321 that was introduced with https://invent.kde.org/unmaintained/kdelibs/-/commit/d2c9a3910f813715a82daa3285bdaa02142ac6b0
- kpac uses it for converting downloaded data from an unknown encoding to QString: https://invent.kde.org/frameworks/kio/-/blob/master/src/kpac/downloader.cpp#L68
- LegacyCodec in kio_file subclasses it: https://invent.kde.org/frameworks/kio/-/blob/master/src/ioslaves/file/legacycodec.h. The purpose of this is unclear to me
- DataProtocol uses it to convert from some encoding to UTF-8: https://invent.kde.org/frameworks/kio/-/blob/master/src/core/dataprotocol.cpp#L271. Not sure how this is used exactly
- sessiondata uses QTextCodec::codecForLocale() as a default value. https://invent.kde.org/frameworks/kio/-/blob/master/src/core/sessiondata.cpp#L88
- kremoteencoding uses QTextCodec internally
- KEncodingFileDialog uses it internally, but that's supposed to get deprecated anyway T12211
KBookmarks uses QTextCodec/KCharset in the netscape bookmark importer for converting from QTextCodec::codecForLocale() or UTF-8. Given that Netscapt isn't too relevant these days the whole thing can maybe get killed?
KFileMetaData's plaintextextractor uses QTextCodec::codecForLocale and assumes that the processed text is in that locale. Maybe it should use KEncodingProber to try to find the right one?
KCodecAction uses QTextCodec::codecForLocale() as a fallback when the mib isn't found