diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-10-28 00:00:21 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-10-28 00:00:21 +0300 |
| commit | d96b8c7d12fc61ec609d6138627b9d6d18139a9a (patch) | |
| tree | 82bc9a4c2b22de6c021097fb79a57b6d7756a127 /utf9/main.c | |
| download | tri-d96b8c7d12fc61ec609d6138627b9d6d18139a9a.tar.gz tri-d96b8c7d12fc61ec609d6138627b9d6d18139a9a.zip | |
move to monorepo
+ Will probably have to make some changes to dir layout to make things
make more sense
Diffstat (limited to 'utf9/main.c')
| -rw-r--r-- | utf9/main.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/utf9/main.c b/utf9/main.c new file mode 100644 index 0000000..54be9dd --- /dev/null +++ b/utf9/main.c @@ -0,0 +1,24 @@ +#include <utf9.h> + +#define STRING "𐍈𐍈𐍈𐍈" +int main() +{ + /* not strictly portable, assumes locale is utf8, etc. */ + const char *s = STRING; + tri_t t[20]; + size_t c = 0; + /* note 20 * 3, as t is in tri words but each word is three 'chars' */ + /* unsure if this is more or less confusing than using the word sizes + * directly */ + size_t l = utf8_to_utf9(t, 20 * 3, s, sizeof(STRING), &c); + printf("utf8->utf9: %llu characters to %llu\n", c, l); + + char r[20]; + /* hmm, currently it's kind of difficult to tell if we just ran out of + * buffer space or failed due to some other issue. */ + l = utf9_to_utf8(r, 20, t, l, &c); + printf("utf9->utf8: %llu characters to %llu\n", c, l); + + printf("original : %s\n", s); + printf("converted : %s\n", r); +} |
