diff options
| author | Tyge Løvset <[email protected]> | 2022-06-10 08:41:01 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-06-10 08:41:01 +0200 |
| commit | f1d09dfcc7570e69eb6e9688b736f7b031b22b2d (patch) | |
| tree | 461d077630b735851ce901ad90e70e4b299ffe98 /include | |
| parent | d463acdbee5bb3a9509cb8414602f495408583b4 (diff) | |
| download | STC-modified-f1d09dfcc7570e69eb6e9688b736f7b031b22b2d.tar.gz STC-modified-f1d09dfcc7570e69eb6e9688b736f7b031b22b2d.zip | |
Some changes to utf8 cstr methods.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cstr.h | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index b0fa276f..2dc2ccae 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -178,33 +178,26 @@ extern void cstr_foldcase(cstr* self); extern void cstr_lowercase(cstr* self); extern void cstr_uppercase(cstr* self); -STC_INLINE bool cstr_valid_u8(const cstr* self) +STC_INLINE bool cstr_valid_utf8(const cstr* self) { return utf8_valid(cstr_str(self)); } // other utf8 -STC_INLINE size_t cstr_size_u8(cstr s) +STC_INLINE size_t cstr_u8size(cstr s) { return utf8_size(cstr_str(&s)); } -STC_INLINE size_t cstr_size_n_u8(cstr s, size_t nbytes) +STC_INLINE size_t cstr_u8size_n(cstr s, size_t nbytes) { return utf8_size_n(cstr_str(&s), nbytes); } -STC_INLINE csview cstr_at(const cstr* self, size_t bytepos) { - csview sv = cstr_sv(self); - sv.str += bytepos; - sv.size = utf8_codep_size(sv.str); - return sv; -} - -STC_INLINE csview cstr_at_u8(const cstr* self, size_t u8idx) { +STC_INLINE csview cstr_view_at(const cstr* self, size_t u8idx) { csview sv = cstr_sv(self); sv.str = utf8_at(sv.str, u8idx); sv.size = utf8_codep_size(sv.str); return sv; } -STC_INLINE size_t cstr_pos_u8(const cstr* self, size_t u8idx) - { return utf8_pos(cstr_str(self), u8idx); } +STC_INLINE const char* cstr_at(const cstr* self, size_t u8idx) + { return utf8_at(cstr_str(self), u8idx); } // utf8 iterator |
