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
@@ -273,7 +273,7 @@ Architecture gpt_partition_type_uuid_to_arch(sd_id128_t id) {
int gpt_partition_label_valid(const char *s) {
_cleanup_free_ char16_t *recoded = NULL;
recoded = utf8_to_utf16(s, strlen(s));
recoded = utf8_to_utf16(s, SIZE_MAX);
if (!recoded)
return -ENOMEM;