diff --git a/src/unicode.hh b/src/unicode.hh index a385b6eb3..fd35ecf09 100644 --- a/src/unicode.hh +++ b/src/unicode.hh @@ -60,12 +60,23 @@ inline bool is_blank(Codepoint c) noexcept is_horizontal_blank(c) ; } +inline bool is_basic_alpha(Codepoint c) noexcept +{ + return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z'); +} + +inline bool is_basic_digit(Codepoint c) noexcept +{ + return c >= '0' and c <= '9'; +} + enum WordType { Word, WORD }; template inline bool is_word(Codepoint c, ConstArrayView extra_word_chars = {'_'}) noexcept { - return iswalnum((wchar_t)c) or contains(extra_word_chars, c); + return (c < 128 ? is_basic_alpha(c) or is_basic_digit(c) : iswalnum((wchar_t)c)) or + contains(extra_word_chars, c); } template<> @@ -79,16 +90,6 @@ inline bool is_punctuation(Codepoint c, ConstArrayView extra_word_cha return not (is_word(c, extra_word_chars) or is_blank(c)); } -inline bool is_basic_alpha(Codepoint c) noexcept -{ - return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z'); -} - -inline bool is_basic_digit(Codepoint c) noexcept -{ - return c >= '0' and c <= '9'; -} - inline bool is_identifier(Codepoint c) noexcept { return is_basic_alpha(c) or is_basic_digit(c) or