added stringutil::to_string

This commit is contained in:
MihailRis 2024-01-11 04:10:43 +03:00
parent 290fec379e
commit 213eba6072
2 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include <vector>
#include <locale>
#include <iomanip>
#include <sstream>
#include <stdexcept>
#include <algorithm>
@ -162,3 +163,9 @@ void util::trim(std::string &s) {
rtrim(s);
ltrim(s);
}
std::wstring util::to_wstring(double x, int precision) {
std::wstringstream ss;
ss << std::fixed << std::setprecision(precision) << x;
return ss.str();
}

View File

@ -19,6 +19,8 @@ namespace util {
extern void ltrim(std::string &s);
extern void rtrim(std::string &s);
extern void trim(std::string &s);
extern std::wstring to_wstring(double x, int precision);
}
#endif // UTIL_STRINGUTIL_H_