summaryrefslogtreecommitdiffhomepage
path: root/src/utf8code.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-06-10 08:41:01 +0200
committerTyge Løvset <[email protected]>2022-06-10 08:41:01 +0200
commitf1d09dfcc7570e69eb6e9688b736f7b031b22b2d (patch)
tree461d077630b735851ce901ad90e70e4b299ffe98 /src/utf8code.c
parentd463acdbee5bb3a9509cb8414602f495408583b4 (diff)
downloadSTC-modified-f1d09dfcc7570e69eb6e9688b736f7b031b22b2d.tar.gz
STC-modified-f1d09dfcc7570e69eb6e9688b736f7b031b22b2d.zip
Some changes to utf8 cstr methods.
Diffstat (limited to 'src/utf8code.c')
-rw-r--r--src/utf8code.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/utf8code.c b/src/utf8code.c
index 1c1e4336..a6ecdb65 100644
--- a/src/utf8code.c
+++ b/src/utf8code.c
@@ -46,10 +46,11 @@ unsigned utf8_encode(char *out, uint32_t c)
}
uint32_t utf8_peek(const char* s, int pos) {
- int inc = 1;
- if (pos < 0) pos = -pos, inc = -1;
+ int inc = -1;
+ if (pos > 0)
+ pos = -pos, inc = 1;
while (pos)
- pos -= (*(s += inc) & 0xC0) != 0x80;
+ pos += (*(s += inc) & 0xC0) != 0x80;
utf8_decode_t d = {.state=0};
do { utf8_decode(&d, (uint8_t)*s++); } while (d.state);
return d.codep;