From 633c77d7cd2dd5cd22018aca17da1490e34d94ec Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 10 Jun 2024 13:40:32 +0800 Subject: test: develop SubProcess test, fix various error. NEED TEST: BufferStream, AutoReadStream, SubProcess. --- src/common/String.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/common/String.cpp') diff --git a/src/common/String.cpp b/src/common/String.cpp index b2e52e67..8736c775 100644 --- a/src/common/String.cpp +++ b/src/common/String.cpp @@ -33,11 +33,19 @@ String String::FromUtf8(const char* str, Index size) { Utf8CodePointIterator iter(str, size); for (auto cp : iter) { Utf16EncodeCodePointAppend( - cp, std::bind(&String::push_back, result, std::placeholders::_1)); + cp, std::bind(&String::push_back, std::ref(result), std::placeholders::_1)); } return result; } +String String::FromUtf8(const std::byte* str, Index size) { + return String::FromUtf8(reinterpret_cast(str), size); +} + +String String::FromUtf8(const Buffer& buffer) { + return String::FromUtf8(buffer.GetUsedBeginPtr(), buffer.GetUsedSize()); +} + String String::FromStdPath(const std::filesystem::path& path) { return String::FromUtf8(path.string()); } @@ -301,7 +309,7 @@ String& String::Trim() { void String::AppendCodePoint(CodePoint code_point) { if (!Utf16EncodeCodePointAppend( code_point, - std::bind(&String::push_back, *this, std::placeholders::_1))) { + std::bind(&String::push_back, this, std::placeholders::_1))) { throw TextEncodeException(u"Code point out of range."); } } @@ -532,7 +540,7 @@ std::string StringView::ToUtf8() const { std::string result; for (auto cp : CodePointIterator()) { Utf8EncodeCodePointAppend( - cp, std::bind(&std::string::push_back, result, std::placeholders::_1)); + cp, std::bind(&std::string::push_back, std::ref(result), std::placeholders::_1)); } return result; } -- cgit v1.2.3