From 00ac3a64ba57ecd8f10bf54f03297cdec0c538d6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 24 Aug 2023 18:32:46 +0900 Subject: Introduce `at_char_boundary` function --- internal/string.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'internal') diff --git a/internal/string.h b/internal/string.h index 5f59d9621b..cfaf628e02 100644 --- a/internal/string.h +++ b/internal/string.h @@ -119,6 +119,12 @@ is_broken_string(VALUE str) return rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN; } +static inline bool +at_char_boundary(const char *s, const char *p, const char *e, rb_encoding *enc) +{ + return rb_enc_left_char_head(s, p, e, enc) == p; +} + /* expect tail call optimization */ // YJIT needs this function to never allocate and never raise static inline VALUE -- cgit v1.2.3