Skip to content

Commit 5f586d4

Browse files
committed
[WASimClient] Prevent locale-specific number formatting rules from affecting client name and RPN code generation; Fixes #25
1 parent 3959a03 commit 5f586d4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/WASimClient/WASimClient.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ prior written authorization from the authors.
3030
#include <iomanip>
3131
#include <iostream>
3232
#include <list>
33+
#include <locale>
3334
#include <set>
3435
#include <shared_mutex>
3536
#include <string>
@@ -316,10 +317,18 @@ class WASimClient::Private
316317
#pragma endregion
317318
#pragma region Constructor and status ----------------------------------------------
318319

320+
// Returns integer ID as 8 char hex string using neutral locale formatting.
321+
static std::string makeClientName(uint32_t id) {
322+
std::ostringstream oss;
323+
oss.imbue(std::locale::classic());
324+
oss << STREAM_HEX8(id);
325+
return oss.str();
326+
}
327+
319328
Private(WASimClient *qptr, uint32_t clientId, const std::string &config) :
320329
q{qptr},
321330
clientId{clientId},
322-
clientName{(ostringstream() << STREAM_HEX8(clientId)).str()}
331+
clientName{makeClientName(clientId)}
323332
{
324333
error_code ec;
325334
filesystem::path cwd = filesystem::current_path(ec);
@@ -1000,6 +1009,7 @@ class WASimClient::Private
10001009

10011010
// Build the RPN code string.
10021011
ostringstream codeStr = ostringstream();
1012+
codeStr.imbue(std::locale::classic());
10031013
codeStr << fixed << setprecision(7) << value;
10041014
codeStr << " (>" << v.variableType << ':' << v.variableName;
10051015
if (v.variableType == 'A' && v.simVarIndex)

0 commit comments

Comments
 (0)