diff options
| author | Tyge Løvset <[email protected]> | 2022-01-12 15:45:14 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-01-12 15:45:14 +0100 |
| commit | ff08e1bb0469750aff5367ae2534278a739bb5d3 (patch) | |
| tree | 04f56c124197286d18c2609cb558399273163aac /include/stc | |
| parent | 7bbfc768d3278b714b8e921ed6124dc359dc1daa (diff) | |
| download | STC-modified-ff08e1bb0469750aff5367ae2534278a739bb5d3.tar.gz STC-modified-ff08e1bb0469750aff5367ae2534278a739bb5d3.zip | |
Final utf8 changes.
Diffstat (limited to 'include/stc')
| -rw-r--r-- | include/stc/utf8.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/include/stc/utf8.h b/include/stc/utf8.h index 3041b26e..a9383ef6 100644 --- a/include/stc/utf8.h +++ b/include/stc/utf8.h @@ -47,26 +47,25 @@ STC_INLINE const char *utf8_next(const char *s) }
#ifdef CSVIEW_H_INCLUDED
-STC_INLINE size_t csview_size_utf8(csview sv)
- { return utf8_size(sv.str); }
-
STC_INLINE bool csview_valid_utf8(csview sv)
{ return utf8_valid(sv.str); }
-STC_INLINE csview csview_from_utf8cp(const char* str)
- { return c_make(csview){str, utf8_codepoint_width((uint8_t)str[0])}; }
-
-STC_INLINE csview csview_at_utf8(const char* str, size_t idx)
- { return csview_from_utf8cp(utf8_at(str, idx)); }
+STC_INLINE size_t csview_size_utf8(csview sv)
+ { return utf8_size(sv.str); }
#endif
#ifdef CSTR_H_INCLUDED
-STC_INLINE size_t cstr_size_utf8(cstr s)
- { return utf8_size(cstr_str(&s)); }
-
STC_INLINE bool cstr_valid_utf8(cstr s)
{ return utf8_valid(cstr_str(&s)); }
+STC_INLINE size_t cstr_size_utf8(cstr s)
+ { return utf8_size(cstr_str(&s)); }
+
+STC_INLINE csview cstr_at_utf8(cstr s, size_t idx) {
+ const char* str = utf8_at(cstr_str(&s), idx);
+ csview sv = {str, utf8_codepoint_width((uint8_t)str[0])};
+ return sv;
+}
#endif
// --------------------------- IMPLEMENTATION ---------------------------------
|
