utf8: let's update utf16_to_utf8() a bit

Let's change utf16_to_utf8() prototype to refer to utf16 chars with char16_t rather than void

Let's not cast away a "const" needlessly.

Let's add a few comments.

Let's fix the calculations of the buffer size to allocate, and how long
to run the loop in case of uneven byte numbers
This commit is contained in:
Lennart Poettering
2018-09-25 15:57:47 +02:00
parent 7c42185784
commit 2ac2ff3fc1
2 changed files with 16 additions and 9 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ char *utf8_escape_invalid(const char *s);
char *utf8_escape_non_printable(const char *str);
size_t utf8_encode_unichar(char *out_utf8, char32_t g);
char *utf16_to_utf8(const void *s, size_t length);
char *utf16_to_utf8(const char16_t *s, size_t length /* bytes! */);
int utf8_encoded_valid_unichar(const char *str);
int utf8_encoded_to_unichar(const char *str, char32_t *ret_unichar);