diff options
author | Masahisa Kojima <masahisa.kojima@linaro.org> | 2022-04-28 17:09:34 +0900 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2022-05-03 21:39:22 +0200 |
commit | eca08ce94ceb72358c5fb00e82506c0f74e65e3f (patch) | |
tree | 29ee5dde90ded64112e7b336ca09eb8c74ed5043 /lib | |
parent | d30924f16bdceb4c34bfa1f230b04e91e28d5666 (diff) | |
download | u-boot-eca08ce94ceb72358c5fb00e82506c0f74e65e3f.tar.gz u-boot-eca08ce94ceb72358c5fb00e82506c0f74e65e3f.tar.bz2 u-boot-eca08ce94ceb72358c5fb00e82506c0f74e65e3f.zip |
lib/charset: add u16_strlcat() function
Provide u16 string version of strlcat().
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/charset.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/charset.c b/lib/charset.c index de201cf3b9..bece4985bf 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -416,6 +416,22 @@ u16 *u16_strdup(const void *src) return new; } +size_t u16_strlcat(u16 *dest, const u16 *src, size_t count) +{ + size_t destlen = u16_strlen(dest); + size_t srclen = u16_strlen(src); + size_t ret = destlen + srclen + 1; + + if (destlen >= count) + return ret; + if (ret > count) + srclen -= ret - count; + memcpy(&dest[destlen], src, 2 * srclen); + dest[destlen + srclen] = 0x0000; + + return ret; +} + /* Convert UTF-16 to UTF-8. */ uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size) { |