diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-12-28 07:58:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-12-28 08:00:08 +0300 |
commit | 00197a668b3463ff050d224967407241a98486cb (patch) | |
tree | 697c311b5db79fdd2571e48b67ae4c05e0f5896c /source/blender/blenlib/intern | |
parent | e182d43d3e695a5086e8167b1ed4fc04ef43dbec (diff) |
BLI_string_utf8: add BLI_strncpy_utf8_rlen
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/string_utf8.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 9697fcf09e9..ef0fcc7f1e3 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -209,6 +209,22 @@ char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t return r_dst; } +size_t BLI_strncpy_utf8_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) +{ + char *r_dst = dst; + + BLI_assert(maxncpy != 0); + +#ifdef DEBUG_STRSIZE + memset(dst, 0xff, sizeof(*dst) * maxncpy); +#endif + + /* note: currently we don't attempt to deal with invalid utf8 chars */ + BLI_STR_UTF8_CPY(dst, src, maxncpy); + + return (size_t)(dst - r_dst); +} + char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) { while (*dst && maxncpy > 0) { |