diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-28 15:44:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-28 15:50:52 +0300 |
commit | 457302b67b9de6a92240c2736306cfa01187101d (patch) | |
tree | eaa6c9fc065aa7fd3730270027f121b709e054ac /source/blender/blenlib/BLI_string_utf8.h | |
parent | 079791dc30571227393db525704baea7540fb5c6 (diff) |
BLI_string_utf8: add buffer size arg to BLI_str_utf8_from_unicode
Besides helping to avoid buffer overflow errors this reduces complexity
of BLI_str_utf32_as_utf8 which needed a special loop for the last 6
characters to avoid writing past the buffer bounds.
Also add BLI_str_utf8_from_unicode_len which only returns the length.
Diffstat (limited to 'source/blender/blenlib/BLI_string_utf8.h')
-rw-r--r-- | source/blender/blenlib/BLI_string_utf8.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h index 937b36758f2..3b7463affc0 100644 --- a/source/blender/blenlib/BLI_string_utf8.h +++ b/source/blender/blenlib/BLI_string_utf8.h @@ -48,7 +48,9 @@ unsigned int BLI_str_utf8_as_unicode_step_or_error( const char *__restrict p, size_t p_len, size_t *__restrict index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 3); -size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf); +size_t BLI_str_utf8_from_unicode_len(unsigned int c) ATTR_WARN_UNUSED_RESULT; +size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf, const size_t outbuf_len) + ATTR_NONNULL(2); size_t BLI_str_utf8_as_utf32(char32_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy) ATTR_NONNULL(1, 2); |