From af3f4c14ee752afde7eb5d3aeb7038a66a8ed298 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Wed, 20 Oct 2021 14:06:52 -0700 Subject: utf: Change argument order Also, make utf8dec take unsigned char * to avoid overflow when converting to signed char. --- utf.c | 6 +++--- utf.h | 6 +++--- 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); -- cgit v1.2.3