Created
August 11, 2026 21:02
-
-
Save jsm222/9b602088f233ccfd24bf173d30d3879f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include <locale.h> | |
| #include <cstring> | |
| #include <QString> | |
| #include <QDebug> | |
| #include <langinfo.h> | |
| int main() { | |
| setlocale(LC_ALL, ""); | |
| // std::string's SSO usually saves this the need to allocate: | |
| const std::string oldEncoding = nl_langinfo(CODESET); | |
| if (!Q_LIKELY(qstricmp(oldEncoding.data(), "UTF-8") == 0 | |
| || qstricmp(oldEncoding.data(), "utf8") == 0)) { | |
| qDebug() << oldEncoding.data(); | |
| const QByteArray oldLocale = setlocale(LC_ALL, nullptr); | |
| QByteArray newLocale; | |
| bool warnOnOverride = true; | |
| } | |
| return 0; | |
| } | |
| //c++ t.cpp -I /usr/local/include/qt6/QtCore -I /usr/local/include/qt6/ -L /usr/local/lib/qt6/ -lQt6Core -o localetest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment