Merge pull request #836 from MihailRis/fixes

std::locale
This commit is contained in:
MihailRis 2026-05-04 21:14:16 +03:00 • committed by GitHub
commit 82a3f9935a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,7 +7,25 @@
#include <sstream>
#include <stdexcept>
static std::locale locale("en_US.UTF-8");
static std::locale get_utf8_locale() {
std::vector<std::string> candidates = {
"C.UTF-8",
"en_US.UTF-8",
"en_US.utf8",
".UTF8",
};
for (const auto& name : candidates) {
try {
return std::locale(name);
} catch (const std::runtime_error&) {
continue;
}
}
return std::locale::classic();
}
static std::locale locale = get_utf8_locale();
std::string util::escape(std::string_view s, bool escapeUnicode) {
std::stringstream ss;