Skip to content

Commit

Permalink
Try to set global locale on start, then just use global in getCasing
Browse files Browse the repository at this point in the history
Should fix #28
  • Loading branch information
unhammer committed Apr 16, 2019
1 parent 722eeaa commit 15a17e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/suggest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/suggest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

1 comment on commit 15a17e1

@unhammer
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mpv-player/mpv@1e70e82 "explains" "why" "this" "is" "needed"

Please sign in to comment.