mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 08:20:44 +00:00
AK: Add String::from_utf8_with_replacement_character
This takes a byte sequence and converts it to a UTF-8 string with the replacement character.
This commit is contained in:
parent
84a09476ba
commit
033ea0e7fb
Notes:
github-actions[bot]
2024-08-10 08:47:28 +00:00
Author: https://github.com/shannonbooth
Commit: 033ea0e7fb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1023
Reviewed-by: https://github.com/awesomekling
3 changed files with 26 additions and 0 deletions
|
@ -20,6 +20,16 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
String String::from_utf8_with_replacement_character(StringView view)
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
for (auto c : Utf8View { view })
|
||||
builder.append_code_point(c);
|
||||
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
String String::from_utf8_without_validation(ReadonlyBytes bytes)
|
||||
{
|
||||
String result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue