aboutsummaryrefslogtreecommitdiff
path: root/src/common/string_util.cpp
diff options
context:
space:
mode:
authorlat9nq <lat9nq@gmail.com>2022-05-15 18:06:33 -0400
committerlat9nq <lat9nq@gmail.com>2022-05-15 18:06:33 -0400
commitffd3afcf2fec718c86d664ede2fa3801b8fc746c (patch)
tree5735e89ac2e9f58c1128c2c1ac323180b063f478 /src/common/string_util.cpp
parent5808e76fae6a6fdc83359685e34102f1f449bb52 (diff)
string_util: Add U16StringFromBuffer
Qt's QString::toStdU16String doesn't work when compiling against the latest libstdc++, at least when using Clang. This function effectively does the same thing as the aforementioned one.
Diffstat (limited to 'src/common/string_util.cpp')
-rw-r--r--src/common/string_util.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 703aa5db82..7a495bc798 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -178,6 +178,10 @@ std::wstring UTF8ToUTF16W(const std::string& input) {
#endif
+std::u16string U16StringFromBuffer(const u16* input, std::size_t length) {
+ return std::u16string(reinterpret_cast<const char16_t*>(input), length);
+}
+
std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len) {
std::size_t len = 0;
while (len < buffer.length() && len < max_len && buffer[len] != '\0') {