diff options
Diffstat (limited to 'sys/libunicode/canfit.c')
-rw-r--r-- | sys/libunicode/canfit.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/libunicode/canfit.c b/sys/libunicode/canfit.c index d44c9e6..4579ab3 100644 --- a/sys/libunicode/canfit.c +++ b/sys/libunicode/canfit.c @@ -7,14 +7,17 @@ utf8·canfit(byte* s, int n) int i; rune c; - if(n <= 0) return 0; - c = *(ubyte*) s; - if(c < Tx) return 1; + if(n <= 0) + return 0; - for(i = 3; i < UTFmax + 1; i++){ - if(c < Tbyte(i)) - return n >= i - 1; - } + c = *(ubyte*)s; + if(c < TByte1) + return 1; + + if(c < TByte3) + return n >= 2; + if(c < TByte4) + return n >= 3; return n >= UTFmax; } |