From c70529c1ec1092d3317316534155344e498fa593 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 9 Nov 2018 17:03:54 -0500 Subject: string_util: Implement buffer to UTF-16 string helper function Needed as most all software keyboard functions use fixed-length UTF16 string buffers. --- src/common/string_util.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/common/string_util.h') diff --git a/src/common/string_util.h b/src/common/string_util.h index 08f96533b..95b7badaf 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -66,6 +66,14 @@ bool ComparePartialString(InIt begin, InIt end, const char* other) { */ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len); +/** + * Creates a UTF-16 std::u16string from a fixed-size NUL-terminated char buffer. If the buffer isn't + * NUL-terminated, then the string ends at the greatest multiple of two less then or equal to + * max_len_bytes. + */ +std::u16string UTF16StringFromFixedZeroTerminatedBuffer(const char16_t* buffer, + std::size_t max_len); + /** * Attempts to trim an arbitrary prefix from `path`, leaving only the part starting at `root`. It's * intended to be used to strip a system-specific build directory from the `__FILE__` macro, -- cgit v1.2.3 From e696ed1f4d20f28f8b26c637498962938df7d96f Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 11 Nov 2018 16:39:25 -0500 Subject: am: Deglobalize software keyboard applet --- src/common/string_util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/string_util.h') diff --git a/src/common/string_util.h b/src/common/string_util.h index 95b7badaf..583fd05e6 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -68,10 +68,10 @@ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t /** * Creates a UTF-16 std::u16string from a fixed-size NUL-terminated char buffer. If the buffer isn't - * NUL-terminated, then the string ends at the greatest multiple of two less then or equal to + * null-terminated, then the string ends at the greatest multiple of two less then or equal to * max_len_bytes. */ -std::u16string UTF16StringFromFixedZeroTerminatedBuffer(const char16_t* buffer, +std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, std::size_t max_len); /** -- cgit v1.2.3