|
|
@@ -10,7 +10,6 @@
|
|
|
|
|
|
using namespace boost::archive::iterators;
|
|
|
|
|
|
-
|
|
|
unsigned char ToHex(unsigned char x)
|
|
|
{
|
|
|
return x > 9 ? x + 55 : x + 48;
|
|
|
@@ -662,3 +661,55 @@ std::string CLewaimaiString::GenerateRandomStr(size_t len, bool useTimeSeed)
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+std::string CLewaimaiString::TrimDecimalZero(const std::string& str)
|
|
|
+{
|
|
|
+ std::string result = str;
|
|
|
+
|
|
|
+ size_t dotPos = result.find('.');
|
|
|
+ if (dotPos == std::string::npos)
|
|
|
+ {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ size_t lastNotZero = result.find_last_not_of('0');
|
|
|
+ if (lastNotZero == std::string::npos)
|
|
|
+ {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ result.erase(lastNotZero + 1);
|
|
|
+
|
|
|
+ if (!result.empty() && result[result.length() - 1] == '.')
|
|
|
+ {
|
|
|
+ result.erase(result.length() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
+std::wstring CLewaimaiString::TrimDecimalZero(const std::wstring& str)
|
|
|
+{
|
|
|
+ std::wstring result = str;
|
|
|
+
|
|
|
+ size_t dotPos = result.find(L'.');
|
|
|
+ if (dotPos == std::wstring::npos)
|
|
|
+ {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ size_t lastNotZero = result.find_last_not_of(L'0');
|
|
|
+ if (lastNotZero == std::wstring::npos)
|
|
|
+ {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ result.erase(lastNotZero + 1);
|
|
|
+
|
|
|
+ if (!result.empty() && result[result.length() - 1] == L'.')
|
|
|
+ {
|
|
|
+ result.erase(result.length() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|