ref: 065f07f73e8dcd360a6f1e752cfdca0ac645d2e2
parent: 721a991694830725add39465b9e63f492c4834ff
author: Ali Gholami Rudi <[email protected]>
date: Thu Mar 12 20:03:41 EDT 2020
char: make utf8len more compact
--- a/char.c
+++ b/char.c
@@ -8,10 +8,8 @@
/* return the length of a utf-8 character based on its first byte */
int utf8len(int c)
{
- if (~c & 0x80)
+ if (~c & 0xc0) /* ASCII or invalid */
return c > 0;
- if (~c & 0x40)
- return 1;
if (~c & 0x20)
return 2;
if (~c & 0x10)