aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mbyte.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/mbyte.h')
-rw-r--r--src/nvim/mbyte.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h
index 2f17c706c1..ddac040aae 100644
--- a/src/nvim/mbyte.h
+++ b/src/nvim/mbyte.h
@@ -52,6 +52,16 @@ extern const uint8_t utf8len_tab[256];
#define MB_PTR_BACK(s, p) \
(p -= utf_head_off((char *)(s), (char *)(p) - 1) + 1)
+/// Check whether a given UTF-8 byte is a trailing byte (10xx.xxxx).
+static inline bool utf_is_trail_byte(uint8_t byte)
+ REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE;
+
+static inline bool utf_is_trail_byte(uint8_t const byte)
+{
+ // uint8_t is for clang to use smaller cmp
+ return (uint8_t)(byte & 0xC0U) == 0x80U;
+}
+
static inline CharInfo utf_ptr2CharInfo(char const *p_in)
REAL_FATTR_NONNULL_ALL REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE;