diff options
| author | Tyge Løvset <[email protected]> | 2022-06-10 11:29:17 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-06-10 11:29:17 +0200 |
| commit | 8883fc8108428878d3d6291ba8981cf6df72499c (patch) | |
| tree | 9fbdc79019501714dc984c1fbd5eb2c7ea979bb4 /docs | |
| parent | f1d09dfcc7570e69eb6e9688b736f7b031b22b2d (diff) | |
| download | STC-modified-8883fc8108428878d3d6291ba8981cf6df72499c.tar.gz STC-modified-8883fc8108428878d3d6291ba8981cf6df72499c.zip | |
utf8 fixes and improvements. Some api changes.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/cstr_api.md | 5 | ||||
| -rw-r--r-- | docs/csview_api.md | 10 |
2 files changed, 8 insertions, 7 deletions
diff --git a/docs/cstr_api.md b/docs/cstr_api.md index cfc807f6..efbb0c5e 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -87,8 +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 -const char* cstr_at(const cstr* self, size_t u8idx); // byte position at utf8 index -csview cstr_view_at(const cstr* self, size_t u8idx); // utf8 codepoint at utf8 pos as csview +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 // iterate utf8 codepoints cstr_iter cstr_begin(const cstr* self); diff --git a/docs/csview_api.md b/docs/csview_api.md index 4baba506..fcdb9f72 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -51,24 +51,24 @@ csview csview_token(csview sv, csview sep, size_t* start); // see sp #### UTF8 methods ```c -size_t csview_size_u8(csview sv); -csview csview_substr_u8(csview sv, size_t u8pos, size_t u8len); +size_t csview_u8size(csview sv); +csview csview_u8substr(csview sv, size_t u8pos, size_t u8len); csview_iter csview_begin(const csview* self); csview_iter csview_end(const csview* self); void csview_next(csview_iter* it); // utf8 codepoint step, not byte! // requires linking with src/utf8code.c: -bool csview_valid_u8(csview sv); +bool csview_valid_utf8(csview sv); // from utf8.h/utf8code.c: bool utf8_valid(const char* s); bool utf8_valid_n(const char* s, size_t n); size_t utf8_size(const char *s); -size_t utf8_size_n(const char *s, size_t n); // number of UTF8 codepoints within n bytes +size_t utf8_size_n(const char *s, size_t nbytes); // number of UTF8 codepoints within n bytes const char* utf8_at(const char *s, size_t index); // from UTF8 index to char* position size_t utf8_pos(const char* s, size_t index); // from UTF8 index to byte index position -unsigned utf8_codep_size(const char* s); // 0-4 (0 if s[0] is illegal utf8) +unsigned utf8_chr_size(const char* s); // 0-4 (0 if s[0] is illegal utf8) uint32_t utf8_decode(utf8_decode_t *d, uint8_t byte); // decode next byte to utf8, return state. unsigned utf8_encode(char *out, uint32_t cp); // encode unicode cp into out buffer ``` |
