mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:07:36 +00:00
AK: Expose Base64 tables from Base64.h
This change is necessary to move the forgiving base64 decoder to LibWeb
This commit is contained in:
parent
6e93d89ee3
commit
4ab2954210
2 changed files with 29 additions and 27 deletions
21
AK/Base64.h
21
AK/Base64.h
|
@ -13,6 +13,27 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
constexpr Array base64_alphabet = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '+', '/'
|
||||
};
|
||||
|
||||
consteval auto base64_lookup_table()
|
||||
{
|
||||
Array<i16, 256> table;
|
||||
table.fill(-1);
|
||||
for (size_t i = 0; i < base64_alphabet.size(); ++i) {
|
||||
table[base64_alphabet[i]] = static_cast<i16>(i);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t calculate_base64_decoded_length(StringView);
|
||||
|
||||
[[nodiscard]] size_t calculate_base64_encoded_length(ReadonlyBytes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue