mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-26 18:00:38 +00:00
fix: make info strings case insensitive (#871)
This commit is contained in:
@@ -4,6 +4,14 @@
|
||||
#include <cctype>
|
||||
#include <sstream>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool ichar_equals(const char a, const char b)
|
||||
{
|
||||
return std::tolower(static_cast<unsigned char>(a)) == std::tolower(static_cast<unsigned char>(b));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace utils
|
||||
{
|
||||
std::string EscapeStringForQuotationMarks(const std::string_view& str)
|
||||
@@ -115,6 +123,11 @@ namespace utils
|
||||
c = static_cast<char>(toupper(static_cast<unsigned char>(c)));
|
||||
}
|
||||
|
||||
bool StringEqualsIgnoreCase(std::string_view lhs, std::string_view rhs)
|
||||
{
|
||||
return std::ranges::equal(lhs, rhs, ichar_equals);
|
||||
}
|
||||
|
||||
void StringTrimL(std::string& str)
|
||||
{
|
||||
str.erase(str.begin(),
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace utils
|
||||
@@ -18,6 +20,8 @@ namespace utils
|
||||
void MakeStringUpperCase(char* str);
|
||||
void MakeStringUpperCase(std::string& str);
|
||||
|
||||
bool StringEqualsIgnoreCase(std::string_view lhs, std::string_view rhs);
|
||||
|
||||
void StringTrimL(std::string& str);
|
||||
void StringTrimR(std::string& str);
|
||||
void StringTrim(std::string& str);
|
||||
|
||||
Reference in New Issue
Block a user