diff options
author | Michael Forney <mforney@mforney.org> | 2021-08-15 00:42:38 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2021-08-15 00:42:38 -0700 |
commit | 1554ecc9334373257b7b3a72971cf25a1179ec16 (patch) | |
tree | beedf06d915f23d7e362a0cc935605508a10c861 | |
parent | 8755378092c00fbae007abbd3f5cb83df0f50ac2 (diff) |
utf: Use C99 types for UTF-16/32 character instead of C11 char16_t/char32_t
Some operating systems do not support uchar.h, and glibc only defines
char16_t/char32_t for GNU C compilers.
-rw-r--r-- | utf.c | 11 | ||||
-rw-r--r-- | utf.h | 6 |
2 files changed, 9 insertions, 8 deletions
@@ -1,8 +1,9 @@ -#include <uchar.h> +#include <stddef.h> +#include <stdint.h> #include "utf.h" size_t -utf8enc(char32_t c, char *s) +utf8enc(uint_least32_t c, char *s) { if (c < 0x80) { s[0] = c; @@ -30,11 +31,11 @@ utf8enc(char32_t c, char *s) } size_t -utf8dec(const char *s, size_t n, char32_t *c) +utf8dec(const char *s, size_t n, uint_least32_t *c) { size_t i, l; unsigned char b; - char32_t x; + uint_least32_t x; b = s[0]; if (b < 0x80) { @@ -64,7 +65,7 @@ utf8dec(const char *s, size_t n, char32_t *c) } size_t -utf16enc(char32_t c, char16_t *s) +utf16enc(uint_least32_t c, uint_least16_t *s) { if (c < 0xd800 || c - 0xe000 < 0x2000) { s[0] = c; @@ -1,3 +1,3 @@ -size_t utf8enc(char32_t, char *); -size_t utf8dec(const char *, size_t, char32_t *); -size_t utf16enc(char32_t, char16_t *); +size_t utf8enc(uint_least32_t, char *); +size_t utf8dec(const char *, size_t, uint_least32_t *); +size_t utf16enc(uint_least32_t, uint_least16_t *); |