mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 19:23:56 +00:00
Fix char16_t tolower conversion
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cwctype>
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
@@ -43,21 +44,18 @@ namespace utils::string
|
||||
return static_cast<char>(std::tolower(static_cast<unsigned char>(val)));
|
||||
}
|
||||
|
||||
inline char16_t char_to_lower(const char16_t val)
|
||||
{
|
||||
if (val >= u'A' && val <= u'Z')
|
||||
{
|
||||
return val + 32;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
inline wchar_t char_to_lower(const wchar_t val)
|
||||
{
|
||||
return static_cast<wchar_t>(std::towlower(val));
|
||||
}
|
||||
|
||||
inline char16_t char_to_lower(const char16_t val)
|
||||
{
|
||||
static_assert(sizeof(char16_t) <= sizeof(wchar_t));
|
||||
static_assert(sizeof(char16_t) == sizeof(uint16_t));
|
||||
return static_cast<char16_t>(char_to_lower(static_cast<wchar_t>(static_cast<uint16_t>(val))));
|
||||
}
|
||||
|
||||
template <class Elem, class Traits, class Alloc>
|
||||
void to_lower_inplace(std::basic_string<Elem, Traits, Alloc>& str)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user