aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-15 20:17:19 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-15 20:21:47 +1300
commitcd6b7311bc24197091517bc86fdbd474052b6a53 (patch)
treeaf2aa09cd97edb8c472017087725524d7171adc1
parentAnother TODO (diff)
downloadwtf8-cd6b7311bc24197091517bc86fdbd474052b6a53.tar.gz
wtf8-cd6b7311bc24197091517bc86fdbd474052b6a53.zip
Resolve a TODO
-rw-r--r--README.markdown8
-rw-r--r--TODO2
-rw-r--r--wtf8.c12
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
------
diff --git a/TODO b/TODO
index 97f2486..8059207 100644
--- a/TODO
+++ b/TODO
@@ -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.
diff --git a/wtf8.c b/wtf8.c
index e4d3f5e..3e09808 100644
--- a/wtf8.c
+++ b/wtf8.c
@@ -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(' ');
}
/*