diff options
author | crupest <crupest@outlook.com> | 2021-11-14 22:27:08 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-11-14 22:27:08 +0800 |
commit | a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0 (patch) | |
tree | 7f22783f8e0c7f61362ef64e879b50729536fea3 /src/common/String.cpp | |
parent | 7045737332f742cec36c3d35f48fad82cd41a04b (diff) | |
download | cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.tar.gz cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.tar.bz2 cru-a744ed1fea0eaf4d946909da7fdc0a4c0f9c5ec0.zip |
...
Diffstat (limited to 'src/common/String.cpp')
-rw-r--r-- | src/common/String.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/common/String.cpp b/src/common/String.cpp index ba31e6f6..8b53b16b 100644 --- a/src/common/String.cpp +++ b/src/common/String.cpp @@ -10,16 +10,6 @@ #include <string_view> namespace cru { -String String::FromUtf8(const char* str) { - return FromUtf16(cru::ToUtf16(std::string_view(str))); -} - -String String::FromUtf8(const char* str, Index size) { - return FromUtf16(cru::ToUtf16(std::string_view(str, size))); -} - -char16_t String::kEmptyBuffer[1] = {0}; - template <typename C> Index GetStrSize(const C* str) { Index i = 0; @@ -29,6 +19,16 @@ Index GetStrSize(const C* str) { return i; } +String String::FromUtf8(const char* str) { + return FromUtf16(cru::ToUtf16(str, GetStrSize(str))); +} + +String String::FromUtf8(const char* str, Index size) { + return FromUtf16(cru::ToUtf16(str, size)); +} + +char16_t String::kEmptyBuffer[1] = {0}; + String::String(const_pointer str) : String(str, GetStrSize(str)) {} String::String(const_pointer str, Index size) { @@ -211,9 +211,7 @@ String::iterator String::erase(const_iterator start, const_iterator end) { return s; } -std::string String::ToUtf8() const { - return cru::ToUtf8(std::u16string_view(data(), size())); -} +std::string String::ToUtf8() const { return cru::ToUtf8(buffer_, size_); } void String::AppendCodePoint(CodePoint code_point) { if (!Utf16EncodeCodePointAppendWithFunc( |