aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2021-10-20 14:06:52 -0700
committerMichael Forney <mforney@mforney.org>2021-10-20 14:10:44 -0700
commitaf3f4c14ee752afde7eb5d3aeb7038a66a8ed298 (patch)
tree348f2c9d3e87c38a3dc31b55711e601b8bd3fb57
parentf3391dde28a8ab2a6652cd43c7f58cafa04a5861 (diff)
utf: Change argument order
Also, make utf8dec take unsigned char * to avoid overflow when converting to signed char.
-rw-r--r--utf.c6
-rw-r--r--utf.h6
2 files changed, 6 insertions, 6 deletions
diff --git a/utf.c b/utf.c
index b012184..de65172 100644
--- a/utf.c
+++ b/utf.c
@@ -3,7 +3,7 @@
#include "utf.h"
size_t
-utf8enc(uint_least32_t c, char *s)
+utf8enc(unsigned char *s, uint_least32_t c)
{
if (c < 0x80) {
s[0] = c;
@@ -31,7 +31,7 @@ utf8enc(uint_least32_t c, char *s)
}
size_t
-utf8dec(const char *s, size_t n, uint_least32_t *c)
+utf8dec(uint_least32_t *c, const char *s, size_t n)
{
size_t i, l;
unsigned char b;
@@ -67,7 +67,7 @@ utf8dec(const char *s, size_t n, uint_least32_t *c)
}
size_t
-utf16enc(uint_least32_t c, uint_least16_t *s)
+utf16enc(uint_least16_t *s, uint_least32_t c)
{
if (c < 0xd800 || c - 0xe000 < 0x2000) {
s[0] = c;
diff --git a/utf.h b/utf.h
index 5851468..77bd175 100644
--- a/utf.h
+++ b/utf.h
@@ -1,3 +1,3 @@
-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 *);
+size_t utf8enc(unsigned char *, uint_least32_t);
+size_t utf8dec(uint_least32_t *, const char *, size_t);
+size_t utf16enc(uint_least16_t *, uint_least32_t);