mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
AK: Make StringBuilder::try_append_code_point actually fallible
It currently uses the non-fallible `append` method to append each UTF-8 encoded byte of the code point.
This commit is contained in:
parent
aee7c44064
commit
39bda0073e
2 changed files with 31 additions and 1 deletions
|
@ -141,7 +141,7 @@ void StringBuilder::clear()
|
|||
|
||||
ErrorOr<void> StringBuilder::try_append_code_point(u32 code_point)
|
||||
{
|
||||
auto nwritten = AK::UnicodeUtils::code_point_to_utf8(code_point, [this](char c) { append(c); });
|
||||
auto nwritten = TRY(AK::UnicodeUtils::try_code_point_to_utf8(code_point, [this](char c) { return try_append(c); }));
|
||||
if (nwritten < 0) {
|
||||
TRY(try_append(0xef));
|
||||
TRY(try_append(0xbf));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue