diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-15 19:40:54 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-12-15 19:40:54 +1300 |
commit | 1f6f97aec816c1ecfb816ba3df64054e8bd84458 (patch) | |
tree | cd53dfbab1f570ffe717630b51d31dd741e9c72a | |
parent | Move includes into header file (diff) | |
download | wtf8-1f6f97aec816c1ecfb816ba3df64054e8bd84458.tar.gz wtf8-1f6f97aec816c1ecfb816ba3df64054e8bd84458.zip |
Move magic constant test into separate function
-rw-r--r-- | wtf8.c | 6 | ||||
-rw-r--r-- | wtf8.h | 2 |
2 files changed, 7 insertions, 1 deletions
@@ -1,5 +1,9 @@ #include "wtf8.h" +int is_utf8_cont(char c) { + return (c & 0xC0) == 0x80; +} + int main(int argc, char **argv) { char *p; int c; @@ -12,7 +16,7 @@ int main(int argc, char **argv) { putchar('\n'); for (p = argv[1]; *p; ) { - for (c = 1; p[c] && (p[c] & 0xC0) == 0x80; c++) + for (c = 1; p[c] && is_utf8_cont(p[c]); c++) printf(" "); putchar(' '); for (; c > 0; c--) @@ -1,2 +1,4 @@ #include <stdio.h> #include <stdlib.h> + +int is_utf8_cont(char); |