diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-15 19:34:12 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-15 19:34:12 +1300 |
commit | 031d3c673a70bc322ce0b7c67b97431607446f42 (patch) | |
tree | 8daa8e9bb7fa36d61ecb55325cfee6350e720801 /wtf8.c | |
download | wtf8-031d3c673a70bc322ce0b7c67b97431607446f42.tar.gz wtf8-031d3c673a70bc322ce0b7c67b97431607446f42.zip |
First commit wtf8(1), tiny UTF-8 inspector
Just committing this first as I know it works, will make it a bit nicer
now.
Diffstat (limited to 'wtf8.c')
-rw-r--r-- | wtf8.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,26 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char **argv) { + char *p; + int c; + + if (argc != 2) + exit(EXIT_FAILURE); + + for (p = argv[1]; *p; p++) + printf("%02x ", (unsigned char) *p); + putchar('\n'); + + for (p = argv[1]; *p; ) { + for (c = 1; p[c] && (p[c] & 0xC0) == 0x80; c++) + printf(" "); + putchar(' '); + for (; c > 0; c--) + putchar(*p++); + putchar(' '); + } + putchar('\n'); + + exit(EXIT_SUCCESS); +} |