refactor: use std::string in tr_info (#2384)

This commit is contained in:
Charles Kerr
2022-01-08 17:41:05 -06:00
committed by GitHub
parent 79d244db82
commit 49f2823d6f
12 changed files with 164 additions and 170 deletions

View File

@@ -164,13 +164,6 @@ std::optional<T> tr_parseNum(std::string_view& sv)
#endif // #if defined(__GNUC__) && !__has_include(<charconv>)
/**
* @brief make a copy of 'str' whose non-utf8 content has been corrected or stripped
* @return a newly-allocated string that must be freed with tr_free()
* @param str the string to make a clean copy of
*/
char* tr_utf8clean(std::string_view str) TR_GNUC_MALLOC;
bool tr_utf8_validate(std::string_view sv, char const** endptr);
#ifdef _WIN32
@@ -300,6 +293,14 @@ std::string tr_strlower(T in)
return out;
}
template<typename T>
std::string tr_strupper(T in)
{
auto out = std::string{ in };
std::for_each(std::begin(out), std::end(out), [](char& ch) { ch = std::toupper(ch); });
return out;
}
/***
**** std::string_view utils
***/