diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-12 16:12:12 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-12 16:12:12 +0200 |
commit | a123eaf6191579870914cb81fe067e3ea87ade76 (patch) | |
tree | bda03bb119355cf19232937ebb6da1110d3eaa8e | |
parent | bd1ab50db89a2298bc0808a7934e7ebe75e848e3 (diff) | |
download | mblaze-a123eaf6191579870914cb81fe067e3ea87ade76.tar.gz mblaze-a123eaf6191579870914cb81fe067e3ea87ade76.tar.xz mblaze-a123eaf6191579870914cb81fe067e3ea87ade76.zip |
scan: fix u8putstr to print the whole glyph at the end
-rw-r--r-- | scan.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scan.c b/scan.c index f0be7c9..906d33a 100644 --- a/scan.c +++ b/scan.c @@ -16,10 +16,14 @@ void u8putstr(FILE *out, char *s, size_t l, int pad) { - while (*s && l > 0) { + while (*s && l) { putc(*s, out); - if ((*s++ & 0xc0) != 0x80) - l--; + // elongate by utf8 overhead + if ((*s & 0xf0) == 0xf0) l += 3; + else if ((*s & 0xe0) == 0xe0) l += 2; + else if ((*s & 0xc0) == 0xc0) l += 1; + l--; + s++; } if (pad) while (l-- > 0) |