diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-15 20:17:19 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-15 20:21:47 +1300 |
commit | cd6b7311bc24197091517bc86fdbd474052b6a53 (patch) | |
tree | af2aa09cd97edb8c472017087725524d7171adc1 | |
parent | Another TODO (diff) | |
download | wtf8-cd6b7311bc24197091517bc86fdbd474052b6a53.tar.gz wtf8-cd6b7311bc24197091517bc86fdbd474052b6a53.zip |
Resolve a TODO
-rw-r--r-- | README.markdown | 8 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | wtf8.c | 12 |
3 files changed, 11 insertions, 11 deletions
diff --git a/README.markdown b/README.markdown index b529465..6af503b 100644 --- a/README.markdown +++ b/README.markdown @@ -9,11 +9,11 @@ with the characters. Expects a single argument, a string. $ make $ sudo make install $ wtf8 test - 74 65 73 74 - t e s t + 74 65 73 74 + t e s t $ wtf8 tøást - 74 c3 b8 c3 a1 73 74 - t ø á s t + 74 c3-b8 c3-a1 73 74 + t ø á s t Author ------ @@ -4,5 +4,3 @@ hiragana). Might be nice to figure out a way to account for this. A manual page. Change it to accept lines on stdin rather than as arguments. - -Change it so that a hyphen appears between bytes that comprise one character. @@ -17,8 +17,11 @@ void print_octets(char *s) { /* * Iterate through the string, printing each octet */ - while (*s) - printf("%02x ", (unsigned char) *s++); + for (; *s; s++) + printf( + is_utf8_cont(*s) ? "-%02x" : " %02x", + (unsigned char) *s + ); /* * End with a newline @@ -52,12 +55,11 @@ void print_characters(char *s) { printf(" "); /* - * Print a space, then the full character, then another space + * Print two spaces, and then the full character */ - putchar(' '); + printf(" "); for (; c > 0; c--) putchar(*s++); - putchar(' '); } /* |