diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-22 19:33:38 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2021-09-20 16:05:31 +1200 |
commit | bcfe32ad1e5178b43c92236f1dbb67a2b53f0b40 (patch) | |
tree | e3ae7810faed1c8352c74664e3f89aecfd92c679 | |
parent | Bump VERSION (diff) | |
download | wtf8-bcfe32ad1e5178b43c92236f1dbb67a2b53f0b40.tar.gz wtf8-bcfe32ad1e5178b43c92236f1dbb67a2b53f0b40.zip |
Make some dense code a little less opaque
-rw-r--r-- | wtf8.c | 9 | ||||
-rw-r--r-- | wtf8.h | 3 |
2 files changed, 10 insertions, 2 deletions
@@ -18,8 +18,13 @@ void print_octets(char *s) { /* * Iterate through the string, printing each octet, ending with a newline */ - while ((c = *s++)) - printf("%c%02x", (is_utf8_cont(c) ? '-' : ' '), c); + while ((c = *s++)) { + char sep; + sep = is_utf8_cont(c) + ? BYTE_SEP + : CHAR_SEP; + printf("%c%02x", sep, c); + } putchar('\n'); return; @@ -2,6 +2,9 @@ #include <stdio.h> #include <stdlib.h> +#define BYTE_SEP '-' +#define CHAR_SEP ' ' + int is_utf8_cont(unsigned char); void print_octets(char *); void print_characters(char *); |