diff options
-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 *); |