Skip to content

Commit 424ae66

Browse files
jonasschnellilaanwj
authored andcommitted
don't imbue boost::filesystem::path with locale "C" on windows
fixes bitcoin#6078 Github-Pull: bitcoin#6093 Rebased-From: b3ffcdf 3da7849
1 parent 9a5b88c commit 424ae66

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/util.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,18 +713,20 @@ void RenameThread(const char* name)
713713

714714
void SetupEnvironment()
715715
{
716-
std::locale loc("C");
717716
// On most POSIX systems (e.g. Linux, but not BSD) the environment's locale
718717
// may be invalid, in which case the "C" locale is used as fallback.
719718
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
720719
try {
721-
loc = std::locale(""); // Raises a runtime error if current locale is invalid
720+
std::locale(""); // Raises a runtime error if current locale is invalid
722721
} catch (const std::runtime_error&) {
723722
setenv("LC_ALL", "C", 1);
724723
}
725724
#endif
726-
// The path locale is lazy initialized and to avoid deinitialization errors
725+
// The path locale is lazy initialized and to avoid deinitialization errors
727726
// in multithreading environments, it is set explicitly by the main thread.
727+
// A dummy locale is used to extract the internal default locale, used by
728+
// boost::filesystem::path, which is then used to explicitly imbue the path.
729+
std::locale loc = boost::filesystem::path::imbue(std::locale::classic());
728730
boost::filesystem::path::imbue(loc);
729731
}
730732

0 commit comments

Comments
 (0)