diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index ed08e758dd..d2177c2208 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -238,14 +238,6 @@ inline bool IsPrintableCharacter(char c) return std::isprint(c, std::locale::classic()); } -/// Returns whether a character is a letter, i.e. whether 'a' <= c <= 'z' || 'A' <= c <= 'Z' -/// is true. Use this instead of calling std::isalpha directly to ensure -/// the C locale is being used and to avoid possibly undefined behaviour. -inline bool IsAlpha(char c) -{ - return std::isalpha(c, std::locale::classic()); -} - #ifdef _WIN32 std::vector CommandLineToUtf8Argv(const wchar_t* command_line); #endif @@ -254,14 +246,24 @@ std::string GetEscapedHtml(std::string html); namespace Common { +/// Returns whether a character is a letter, i.e. whether 'a' <= c <= 'z' || 'A' <= c <= 'Z' +/// is true. Use this instead of calling std::isalpha directly to ensure +/// the C locale is being used and to avoid possibly undefined behaviour. +inline bool IsAlpha(char c) +{ + return std::isalpha(c, std::locale::classic()); +} + 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); bool CaseInsensitiveEquals(std::string_view a, std::string_view b); diff --git a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp index 1c3e997769..e28e044866 100644 --- a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp +++ b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp @@ -43,7 +43,7 @@ std::string GetExpressionForControl(const std::string& control_name, { // If our expression contains any non-alpha characters // we should quote it - if (!std::all_of(expr.begin(), expr.end(), IsAlpha)) + if (!std::all_of(expr.begin(), expr.end(), Common::IsAlpha)) expr = fmt::format("`{}`", expr); }