Add tolower_char(char)->char. Avoids C4244 for char<->int conversion
MODIFY
src/vcpkg_Strings.cpp
src/vcpkg_Strings.cpp
@@ -9,6 +9,11 @@ namespace vcpkg::Strings::details
return std::isspace(c);
};
+ static char tolower_char(const char c)
+ {
+ return static_cast<char>(std::tolower(c));
+ }
+
std::string format_internal(const char* fmtstr, ...)
{
va_list lst;
@@ -53,17 +58,17 @@ namespace vcpkg::Strings
std::string::const_iterator case_insensitive_ascii_find(const std::string& s, const std::string& pattern)
{
std::string pattern_as_lower_case;
- std::transform(pattern.begin(), pattern.end(), back_inserter(pattern_as_lower_case), tolower);
+ std::transform(pattern.begin(), pattern.end(), back_inserter(pattern_as_lower_case), &details::tolower_char);
return search(s.begin(), s.end(), pattern_as_lower_case.begin(), pattern_as_lower_case.end(), [](const char a, const char b)
{
- return tolower(a) == b;
+ return details::tolower_char(a) == b;
});
}
std::string ascii_to_lowercase(const std::string& input)
{
- std::string output = input;
- std::transform(output.begin(), output.end(), output.begin(), ::tolower);
+ std::string output(input);
+ std::transform(output.begin(), output.end(), output.begin(), &details::tolower_char);
return output;
}

Add tolower_char(char)->char. Avoids C4244 for char<->int conversion