mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
fix pretty_name with ENABLE_NONASCII
This commit is contained in:
parent
d5e8530191
commit
d01a4f90a6
1 changed files with 6 additions and 7 deletions
|
|
@ -251,9 +251,9 @@ class static_string<0> {
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr string_view pretty_name(string_view name) noexcept {
|
constexpr string_view pretty_name(string_view name) noexcept {
|
||||||
char const* str = name.data();
|
const char* str = name.data();
|
||||||
for (std::size_t i = name.size(); i > 0; --i) {
|
for (std::size_t i = name.size(); i > 0; --i) {
|
||||||
char c = str[i - 1];
|
const char c = str[i - 1];
|
||||||
if (!((c >= '0' && c <= '9') ||
|
if (!((c >= '0' && c <= '9') ||
|
||||||
(c >= 'a' && c <= 'z') ||
|
(c >= 'a' && c <= 'z') ||
|
||||||
(c >= 'A' && c <= 'Z') ||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
|
|
@ -266,19 +266,18 @@ constexpr string_view pretty_name(string_view name) noexcept {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.size() > 0)
|
if (name.size() > 0) {
|
||||||
{
|
const char c = name[0];
|
||||||
char c = name[0];
|
|
||||||
if ((c >= 'a' && c <= 'z') ||
|
if ((c >= 'a' && c <= 'z') ||
|
||||||
(c >= 'A' && c <= 'Z') ||
|
(c >= 'A' && c <= 'Z') ||
|
||||||
#if defined(MAGIC_ENUM_ENABLE_NONASCII)
|
#if defined(MAGIC_ENUM_ENABLE_NONASCII)
|
||||||
(c) & 0x80) ||
|
(c & 0x80) ||
|
||||||
#endif
|
#endif
|
||||||
(c == '_')) {
|
(c == '_')) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {}; // Invalid name.
|
return {}; // Invalid name.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue