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/findlast.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sys/libunicode/findlast.c') diff --git a/sys/libunicode/findlast.c b/sys/libunicode/findlast.c index 3a4ed38..ab25ab2 100644 --- a/sys/libunicode/findlast.c +++ b/sys/libunicode/findlast.c @@ -7,19 +7,21 @@ utf8·findlast(byte* s, rune c) rune r; byte *l; - if(c < RuneSync) + if(c < Tx) return strrchr(s, c); l = nil; for(;;){ c1 = *(ubyte*)s; - if(c1 < RuneSelf) { + if(c1 < Tx){ if(c1 == 0) return l; if(c1 == c) l = s; s++; continue; } + c1 = utf8·decode(s, &r); + if(r == c) l = s; -- cgit v1.2.1