Create Common::ToLower and Common::ToUpper

This commit is contained in:
Pokechu22 2022-01-16 16:23:12 -08:00
parent e627718560
commit aaec64501a
2 changed files with 27 additions and 0 deletions

View File

@ -669,3 +669,16 @@ std::string GetEscapedHtml(std::string html)
}
return html;
}
namespace Common
{
void ToLower(std::string* str)
{
std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToLower(c); });
}
void ToUpper(std::string* str)
{
std::transform(str->begin(), str->end(), str->begin(), [](char c) { return Common::ToUpper(c); });
}
} // namespace Common

View File

@ -240,3 +240,17 @@ std::vector<std::string> CommandLineToUtf8Argv(const wchar_t* command_line);
#endif
std::string GetEscapedHtml(std::string html);
namespace Common
{
inline char ToLower(char ch)
{
return std::tolower(ch, std::locale::classic());
}
inline char ToUpper(char ch)
{
return std::toupper(ch, std::locale::classic());
}
void ToLower(std::string* str);
void ToUpper(std::string* str);
} // namespace Common