|
|
|
@ -180,20 +180,20 @@ std::wstring UTF8ToUTF16W(const std::string& input) {
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len) {
|
|
|
|
|
std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len) {
|
|
|
|
|
std::size_t len = 0;
|
|
|
|
|
while (len < max_len && buffer[len] != '\0')
|
|
|
|
|
while (len < buffer.length() && len < max_len && buffer[len] != '\0') {
|
|
|
|
|
++len;
|
|
|
|
|
|
|
|
|
|
return std::string(buffer, len);
|
|
|
|
|
}
|
|
|
|
|
return std::string(buffer.begin(), buffer.begin() + len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer,
|
|
|
|
|
std::size_t max_len) {
|
|
|
|
|
std::size_t len = 0;
|
|
|
|
|
while (len < max_len && buffer[len] != '\0')
|
|
|
|
|
while (len < buffer.length() && len < max_len && buffer[len] != '\0') {
|
|
|
|
|
++len;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return std::u16string(buffer.begin(), buffer.begin() + len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|