fix:修正unicode下的编译。

This commit is contained in:
taynpg 2024-12-24 22:07:10 +08:00
parent 8b2905dadc
commit 65f2505515
2 changed files with 11 additions and 5 deletions

View File

@ -33,11 +33,11 @@ std::vector<ofString> COfStr::split(const ofString& input, const ofString& delim
}
ofString COfStr::trim(const ofString& input)
{
size_t start = input.find_first_not_of(" \t\n\r\f\v");
size_t start = input.find_first_not_of(ofT(" \t\n\r\f\v"));
if (start == std::string::npos) {
return "";
return ofT("");
}
size_t end = input.find_last_not_of(" \t\n\r\f\v");
size_t end = input.find_last_not_of(ofT(" \t\n\r\f\v"));
return input.substr(start, end - start + 1);
}
} // namespace ofen

View File

@ -74,9 +74,15 @@ ofString OfUtil::now_time()
#else
localtime_r(&time_t_now, &tm_now);
#endif
std::ostringstream oss;
oss << std::put_time(&tm_now, "%Y-%m-%d %H:%M:%S");
#ifdef UNICODE_OFSTR
std::wostringstream oss;
oss << std::put_time(&tm_now, ofT("%Y-%m-%d %H:%M:%S"));
return oss.str();
#else
std::ostringstream oss;
oss << std::put_time(&tm_now, ofT("%Y-%m-%d %H:%M:%S"));
return oss.str();
#endif
}
#ifdef _WIN32