File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 16
16
*/
17
17
18
18
#include " suggest.hpp"
19
+ #include < locale>
19
20
20
21
namespace divvun {
21
22
@@ -1099,7 +1100,10 @@ void Suggest::mk_errs(Sentence& sentence) {
1099
1100
vector<Err> Suggest::run_errs (std::istream& is) {
1100
1101
std::locale old_locale = std::locale ();
1101
1102
try {
1102
- old_locale = std::locale::global (std::locale (" " )); // Would prefer C.UTF-8, but that doesn't always exist
1103
+ // Use environment locale (we expect some UTF-8 locale) for toUpper/toLower etc.
1104
+ // but C for numbers (to avoid any comma-as-decimal-separator nonsense)
1105
+ std::locale mixed (std::locale (" " ), std::locale::classic (), std::locale::numeric);
1106
+ old_locale = std::locale::global (mixed);
1103
1107
}
1104
1108
catch (const std::runtime_error& e) {
1105
1109
std::cerr
@@ -1226,7 +1230,10 @@ RunState Suggest::run_cg(std::istream& is, std::ostream& os) {
1226
1230
void Suggest::run (std::istream& is, std::ostream& os, RunMode mode) {
1227
1231
std::locale old_locale = std::locale ();
1228
1232
try {
1229
- old_locale = std::locale::global (std::locale (" " )); // Would prefer C.UTF-8, but that doesn't always exist
1233
+ // Use environment locale (we expect some UTF-8 locale) for toUpper/toLower etc.
1234
+ // but C for numbers (to avoid any comma-as-decimal-separator nonsense)
1235
+ std::locale mixed (std::locale (" " ), std::locale::classic (), std::locale::numeric);
1236
+ old_locale = std::locale::global (mixed);
1230
1237
}
1231
1238
catch (const std::runtime_error& e) {
1232
1239
std::cerr
You can’t perform that action at this time.
0 commit comments