From 6318ddb69ad8380694bbca35ca5a72230c2ee694 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Thu, 28 Oct 2021 11:55:47 -0700 Subject: Feat(libunicode): cleaned up decode/encode Additionally, decode can now apply backwards on a byte string. --- sys/libunicode/find.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys/libunicode/find.c') diff --git a/sys/libunicode/find.c b/sys/libunicode/find.c index 659ab5b..d75feb8 100644 --- a/sys/libunicode/find.c +++ b/sys/libunicode/find.c @@ -7,17 +7,18 @@ utf8·find(byte* s, rune c) rune r; int n; - if(c < RuneSync) + if(c < Tx) return strchr(s, c); for(;;){ c1 = *(ubyte*)s; - if(c1 < RuneSelf) { + if(c1 < Tx){ if(c1 == 0) return nil; if(c1 == c) return s; s++; continue; } + n = utf8·decode(s, &r); if(r == c) -- cgit v1.2.1