diff options
Diffstat (limited to 'src/common/String.cpp')
-rw-r--r-- | src/common/String.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
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<const char*>(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; } |