From 15a17e1f33540f044833f5e1d020c7c68c4fa3ee Mon Sep 17 00:00:00 2001 From: Kevin Brubeck Unhammer Date: Tue, 16 Apr 2019 12:11:46 +0200 Subject: [PATCH] Try to set global locale on start, then just use global in getCasing Should fix #28 --- src/suggest.cpp | 7 +++++++ src/suggest.hpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/suggest.cpp b/src/suggest.cpp index 70f688a..deed674 100644 --- a/src/suggest.cpp +++ b/src/suggest.cpp @@ -891,6 +891,13 @@ void run_cg(std::istream& is, std::ostream& os, const hfst::HfstTransducer& t, b void Suggest::run(std::istream& is, std::ostream& os, bool json) { + try { + auto _old = std::locale::global(std::locale("")); + } + catch (const std::runtime_error& e) + { + std::cerr << "WARNING: Couldn't set global locale \"\" (locale-specific native environment): " << e.what() << std::endl; + } if(json) { while(run_json(is, os) == flushing); } diff --git a/src/suggest.hpp b/src/suggest.hpp index 6c0ebc8..f9fc1fc 100644 --- a/src/suggest.hpp +++ b/src/suggest.hpp @@ -82,7 +82,7 @@ inline Casing getCasing(string input) { if(input.length() < 1) { return mIxed; } - std::locale loc(""); + std::locale loc; bool seenupper = false; bool seenlower = false; bool fstupper = false;