We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents df99701 + 30dc02a commit 82a3f99Copy full SHA for 82a3f99
1 file changed
src/util/stringutil.cpp
@@ -7,7 +7,25 @@
7
#include <sstream>
8
#include <stdexcept>
9
10
-static std::locale locale("en_US.UTF-8");
+static std::locale get_utf8_locale() {
11
+ std::vector<std::string> candidates = {
12
+ "C.UTF-8",
13
+ "en_US.UTF-8",
14
+ "en_US.utf8",
15
+ ".UTF8",
16
+ };
17
+
18
+ for (const auto& name : candidates) {
19
+ try {
20
+ return std::locale(name);
21
+ } catch (const std::runtime_error&) {
22
+ continue;
23
+ }
24
25
+ return std::locale::classic();
26
+}
27
28
+static std::locale locale = get_utf8_locale();
29
30
std::string util::escape(std::string_view s, bool escapeUnicode) {
31
std::stringstream ss;
0 commit comments