1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-08-02 03:07:35 +00:00

AK: Stop using DeprecatedString in Base64 encoding

This commit is contained in:
Jelle Raaijmakers 2022-12-19 00:23:47 +01:00 committed by Andreas Kling
parent 99c1b634fc
commit 25f2e4981c
14 changed files with 47 additions and 27 deletions

View file

@ -100,7 +100,7 @@ ErrorOr<ByteBuffer> decode_base64(StringView input)
return ByteBuffer::copy(output);
}
DeprecatedString encode_base64(ReadonlyBytes input)
ErrorOr<String> encode_base64(ReadonlyBytes input)
{
StringBuilder output(calculate_base64_encoded_length(input));
@ -131,13 +131,13 @@ DeprecatedString encode_base64(ReadonlyBytes input)
char const out2 = is_16bit ? '=' : alphabet[index2];
char const out3 = is_8bit ? '=' : alphabet[index3];
output.append(out0);
output.append(out1);
output.append(out2);
output.append(out3);
TRY(output.try_append(out0));
TRY(output.try_append(out1));
TRY(output.try_append(out2));
TRY(output.try_append(out3));
}
return output.to_deprecated_string();
return output.to_string();
}
}

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/String.h>
#include <AK/StringView.h>
namespace AK {
@ -19,7 +19,7 @@ namespace AK {
[[nodiscard]] ErrorOr<ByteBuffer> decode_base64(StringView);
[[nodiscard]] DeprecatedString encode_base64(ReadonlyBytes);
[[nodiscard]] ErrorOr<String> encode_base64(ReadonlyBytes);
}
#if USING_AK_GLOBALLY