mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Add DeprecatedString::from_utf8()
This will be used in Jakt to help transition off of DeprecatedString.
This commit is contained in:
parent
6b497b8710
commit
230cb3b0cb
Notes:
sideshowbarker
2024-07-17 17:49:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/230cb3b0cb
2 changed files with 9 additions and 0 deletions
|
@ -455,4 +455,11 @@ DeprecatedStringCodePointIterator DeprecatedString::code_points() const
|
|||
return DeprecatedStringCodePointIterator(*this);
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> DeprecatedString::from_utf8(ReadonlyBytes bytes)
|
||||
{
|
||||
if (!Utf8View(bytes).validate())
|
||||
return Error::from_string_literal("DeprecatedString::from_utf8: Input was not valid UTF-8");
|
||||
return DeprecatedString { StringImpl::create(bytes) };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -95,6 +95,8 @@ public:
|
|||
|
||||
DeprecatedString(DeprecatedFlyString const&);
|
||||
|
||||
static ErrorOr<DeprecatedString> from_utf8(ReadonlyBytes);
|
||||
|
||||
[[nodiscard]] static DeprecatedString repeated(char, size_t count);
|
||||
[[nodiscard]] static DeprecatedString repeated(StringView, size_t count);
|
||||
|
||||
|
|
Loading…
Reference in a new issue