summaryrefslogtreecommitdiff
path: root/src/common/string_util.cpp
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-11-09 17:03:54 -0500
committerGravatar Zach Hilman2018-11-18 10:53:47 -0500
commitc70529c1ec1092d3317316534155344e498fa593 (patch)
tree3579cf39b113bf8f1f40d80c01a994005c1fb3c8 /src/common/string_util.cpp
parentsvc: Implement svcCreateTransferMemory (diff)
downloadyuzu-c70529c1ec1092d3317316534155344e498fa593.tar.gz
yuzu-c70529c1ec1092d3317316534155344e498fa593.tar.xz
yuzu-c70529c1ec1092d3317316534155344e498fa593.zip
string_util: Implement buffer to UTF-16 string helper function
Needed as most all software keyboard functions use fixed-length UTF16 string buffers.
Diffstat (limited to '')
-rw-r--r--src/common/string_util.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 14f7037d8..a1360dd26 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -214,6 +214,15 @@ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t
214 return std::string(buffer, len); 214 return std::string(buffer, len);
215} 215}
216 216
217std::u16string UTF16StringFromFixedZeroTerminatedBuffer(const char16_t* buffer,
218 std::size_t max_len) {
219 std::size_t len = 0;
220 while (len < max_len && buffer[len] != '\0')
221 ++len;
222
223 return std::u16string(buffer, len);
224}
225
217const char* TrimSourcePath(const char* path, const char* root) { 226const char* TrimSourcePath(const char* path, const char* root) {
218 const char* p = path; 227 const char* p = path;
219 228