aboutsummaryrefslogtreecommitdiff
path: root/wtf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'wtf8.c')
-rw-r--r--wtf8.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/wtf8.c b/wtf8.c
index 40db322..b8839ce 100644
--- a/wtf8.c
+++ b/wtf8.c
@@ -13,19 +13,15 @@ int is_utf8_cont(char c) {
* trailing space, ending with a newline
*/
void print_octets(char *s) {
+ unsigned char c;
/*
- * Iterate through the string, printing each octet
- */
- for (; *s; s++) {
- putchar(is_utf8_cont(*s) ? '-' : ' ');
- printf("%02x", (unsigned char) *s);
- }
-
- /*
- * End with a newline
+ * Iterate through the string, printing each octet, ending with a newline
*/
+ while (c = *s++)
+ printf("%c%02x", (is_utf8_cont(c) ? '-' : ' '), c);
putchar('\n');
+
return;
}