remove undefined behaviour from string util
This commit is contained in:
parent
d45efeee08
commit
f129e137fa
@ -36,9 +36,9 @@ namespace utils::string
|
|||||||
|
|
||||||
std::string to_lower(std::string text)
|
std::string to_lower(std::string text)
|
||||||
{
|
{
|
||||||
std::transform(text.begin(), text.end(), text.begin(), [](const char input)
|
std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input)
|
||||||
{
|
{
|
||||||
return static_cast<char>(tolower(input));
|
return static_cast<char>(std::tolower(input));
|
||||||
});
|
});
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
@ -46,9 +46,9 @@ namespace utils::string
|
|||||||
|
|
||||||
std::string to_upper(std::string text)
|
std::string to_upper(std::string text)
|
||||||
{
|
{
|
||||||
std::transform(text.begin(), text.end(), text.begin(), [](const char input)
|
std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input)
|
||||||
{
|
{
|
||||||
return static_cast<char>(toupper(input));
|
return static_cast<char>(std::toupper(input));
|
||||||
});
|
});
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
@ -147,8 +147,6 @@ namespace utils::string
|
|||||||
*out = '\0';
|
*out = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable: 4100)
|
|
||||||
std::string convert(const std::wstring& wstr)
|
std::string convert(const std::wstring& wstr)
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
@ -174,7 +172,6 @@ namespace utils::string
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#pragma warning(pop)
|
|
||||||
|
|
||||||
std::string replace(std::string str, const std::string& from, const std::string& to)
|
std::string replace(std::string str, const std::string& from, const std::string& to)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user