util/AllocatedString: std::string_view support
This commit is contained in:
@@ -38,12 +38,12 @@ public:
|
||||
|
||||
IcuCompare(const IcuCompare &src) noexcept
|
||||
:needle(src
|
||||
? AllocatedString<>::Duplicate(src.needle.c_str())
|
||||
? AllocatedString<>::Duplicate(src.needle)
|
||||
: nullptr) {}
|
||||
|
||||
IcuCompare &operator=(const IcuCompare &src) noexcept {
|
||||
needle = src
|
||||
? AllocatedString<>::Duplicate(src.needle.c_str())
|
||||
? AllocatedString<>::Duplicate(src.needle)
|
||||
: nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
@@ -95,7 +95,7 @@ DoConvert(iconv_t conv, const char *src)
|
||||
if (in_left > 0)
|
||||
throw std::runtime_error("Charset conversion failed");
|
||||
|
||||
return AllocatedString<>::Duplicate(buffer, sizeof(buffer) - out_left);
|
||||
return AllocatedString<>::Duplicate({buffer, sizeof(buffer) - out_left});
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -151,7 +151,7 @@ IcuConverter::FromUTF8(const char *s) const
|
||||
throw std::runtime_error(FormatString("Failed to convert from Unicode: %s",
|
||||
u_errorName(code)).c_str());
|
||||
|
||||
return AllocatedString<>::Duplicate(buffer, target);
|
||||
return AllocatedString<>::Duplicate({buffer, size_t(target - buffer)});
|
||||
|
||||
#elif defined(HAVE_ICONV)
|
||||
return DoConvert(from_utf8, s);
|
||||
|
Reference in New Issue
Block a user