summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-06-10 11:46:13 +0200
committerTyge Løvset <[email protected]>2022-06-10 11:46:13 +0200
commit6fc13dad84b2b315ea33af180d907e63a632accd (patch)
treefc9bab464437759dab2fd0edfe4ad3d0eeb6540d
parent8883fc8108428878d3d6291ba8981cf6df72499c (diff)
downloadSTC-modified-6fc13dad84b2b315ea33af180d907e63a632accd.tar.gz
STC-modified-6fc13dad84b2b315ea33af180d907e63a632accd.zip
Changed a few cstr utf8 function names.
-rw-r--r--docs/cstr_api.md6
-rw-r--r--examples/cstr_match.c4
-rw-r--r--include/stc/cstr.h6
3 files changed, 8 insertions, 8 deletions
diff --git a/docs/cstr_api.md b/docs/cstr_api.md
index efbb0c5e..57c8c6e0 100644
--- a/docs/cstr_api.md
+++ b/docs/cstr_api.md
@@ -87,9 +87,9 @@ bool cstr_getdelim(cstr *self, int delim, FILE *stream); // does no
```c
size_t cstr_u8size(cstr s); // number of utf8 codepoints
size_t cstr_u8size_n(cstr s, size_t nbytes); // utf8 size within n bytes
-size_t cstr_bytepos(cstr s, size_t u8idx); // byte pos offset at utf8 index
-const char* cstr_at(const cstr* self, size_t u8idx); // char* position at utf8 index
-csview cstr_chr(const cstr* self, size_t u8idx); // utf8 character at utf8 pos as csview
+size_t cstr_pos_u8(cstr s, size_t u8idx); // byte pos offset at utf8 index
+const char* cstr_at_u8(const cstr* self, size_t u8idx); // char* position at utf8 index
+csview cstr_chr_u8(const cstr* self, size_t u8idx); // utf8 character at utf8 pos as csview
// iterate utf8 codepoints
cstr_iter cstr_begin(const cstr* self);
diff --git a/examples/cstr_match.c b/examples/cstr_match.c
index 3965b36a..fd420f62 100644
--- a/examples/cstr_match.c
+++ b/examples/cstr_match.c
@@ -14,8 +14,8 @@ int main()
printf("ends_with: %d\n", cstr_ends_with(ss, ".JPG"));
cstr s1 = cstr_new("hell😀 w😀rl🐨");
- csview ch1 = cstr_chr(&s1, 7);
- csview ch2 = cstr_chr(&s1, 10);
+ csview ch1 = cstr_chr_u8(&s1, 7);
+ csview ch2 = cstr_chr_u8(&s1, 10);
printf("%s\nsize: %" PRIuMAX ", %" PRIuMAX "\n", cstr_str(&s1), cstr_u8size(s1), cstr_size(s1));
printf("ch1: %" c_PRIsv "\n", c_ARGsv(ch1));
printf("ch2: %" c_PRIsv "\n", c_ARGsv(ch2));
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index 41db1cd3..a6d4beb1 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -189,13 +189,13 @@ STC_INLINE size_t cstr_u8size(cstr s)
STC_INLINE size_t cstr_u8size_n(cstr s, size_t nbytes)
{ return utf8_size_n(cstr_str(&s), nbytes); }
-STC_INLINE size_t cstr_bytepos(const cstr* self, size_t u8idx)
+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)
+STC_INLINE const char* cstr_at_u8(const cstr* self, size_t u8idx)
{ return utf8_at(cstr_str(self), u8idx); }
-STC_INLINE csview cstr_chr(const cstr* self, size_t u8idx) {
+STC_INLINE csview cstr_chr_u8(const cstr* self, size_t u8idx) {
csview sv = cstr_sv(self);
sv.str = utf8_at(sv.str, u8idx);
sv.size = utf8_chr_size(sv.str);