utf8: automatically determine length of string if SIZE_MAX is specified

Let's make utf8_to_utf16() and utf16_to_utf8() a bit nicer to use by
adding shortcuts for common cases.

This is particularly relevant for utf16_to_utf8() since the
multiplication with 2 is easy to forget.
This commit is contained in:
Lennart Poettering
2023-08-24 13:19:12 +02:00
parent b56ee69233
commit ba091282e5
6 changed files with 30 additions and 9 deletions
+1 -1
View File
@@ -265,7 +265,7 @@ finish:
int efi_set_variable_string(const char *variable, const char *value) {
_cleanup_free_ char16_t *u16 = NULL;
u16 = utf8_to_utf16(value, strlen(value));
u16 = utf8_to_utf16(value, SIZE_MAX);
if (!u16)
return -ENOMEM;