summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/StringUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/Src/StringUtil.cpp')
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index fface8ae1c..4c1163f345 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -371,3 +371,26 @@ int ChooseStringFrom(const char* str, const char* * items)
}
return -1;
}
+
+
+// Thousand separator. Turns 12345678 into 12,345,678.
+std::string ThS(int a, bool b)
+{
+ char cbuf[20]; int j = 0;
+
+ // determine treatment of signed or unsigned
+ if(b) sprintf(cbuf, "%u", a); else sprintf(cbuf, "%i", a);
+
+
+ std::string sbuf = cbuf;
+ for (int i = 0; i < sbuf.length(); ++i)
+ {
+ if((i & 3) == 3)
+ {
+ sbuf.insert(sbuf.length() - i, ",");
+ }
+ }
+ return sbuf;
+}
+
+