Skip to content

Commit 5248ff4

Browse files
committed
SetupEnvironment() - clean commit
1 parent bfae70a commit 5248ff4

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

src/bitcoin-cli.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ static bool AppInitRPC(int argc, char* argv[])
5858

5959
int main(int argc, char* argv[])
6060
{
61+
SetupEnvironment();
62+
6163
try
6264
{
6365
if(!AppInitRPC(argc, argv))

src/bitcoind.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ bool AppInit(int argc, char* argv[])
172172

173173
int main(int argc, char* argv[])
174174
{
175+
SetupEnvironment();
176+
175177
bool fRet = false;
176178

177179
// Connect bitcoind signal handlers

src/qt/bitcoin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ WId BitcoinApplication::getMainWinId() const
459459
#ifndef BITCOIN_QT_TEST
460460
int main(int argc, char *argv[])
461461
{
462+
SetupEnvironment();
463+
462464
/// 1. Parse command-line options. These take precedence over anything else.
463465
// Command-line options take precedence:
464466
ParseParameters(argc, argv);

src/util.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,3 +1404,19 @@ bool ParseInt32(const std::string& str, int32_t *out)
14041404
n <= std::numeric_limits<int32_t>::max();
14051405
}
14061406

1407+
void SetupEnvironment()
1408+
{
1409+
#ifndef WIN32
1410+
try
1411+
{
1412+
#if BOOST_FILESYSTEM_VERSION == 3
1413+
boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid
1414+
#else // boost filesystem v2
1415+
std::locale(); // Raises runtime error if current locale is invalid
1416+
#endif
1417+
} catch(std::runtime_error &e)
1418+
{
1419+
setenv("LC_ALL", "C", 1); // Force C locale
1420+
}
1421+
#endif
1422+
}

src/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ extern volatile bool fReopenDebugLog;
106106

107107
void RandAddSeed();
108108
void RandAddSeedPerfmon();
109+
void SetupEnvironment();
109110

110111
/* Return true if log accepts specified category */
111112
bool LogAcceptCategory(const char* category);

0 commit comments

Comments
 (0)