How to determine system encoding in Qt 6?
-
wrote 25 days ago last edited by
Previously, I could use
QTextCodec::codecForLocale()
to determine the local encoding in an OS-agnostic way. The main use case was to include it in the application log. At least two times this was key to reproduce an user issue concerning file import. But for Qt6QTextCodec
is only available as a Qt5 compatibility feature.Is there a new, Qt 6 native way to determine the system's local encoding? I couldn't find it in the docs (or other forum posts)
-
I'd do the following:
const QLocale locale = QLocale::system(); const auto encoding = QStringConverter::encodingForName(locale.name().toUtf8());
-
wrote 24 days ago last edited by
Thanks a lot!
-
3/3