mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-28 18:40:29 +00:00
AK: Add the to_ascii_base36_digit helper method
This commit is contained in:
parent
12e66de410
commit
4a2a084789
Notes:
sideshowbarker
2024-07-18 11:20:53 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/4a2a0847892 Pull-request: https://github.com/SerenityOS/serenity/pull/8314
1 changed files with 9 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Array.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
// NOTE: For a quick reference for most of this, see https://www.cplusplus.com/reference/cctype/ and https://infra.spec.whatwg.org/#code-points.
|
// NOTE: For a quick reference for most of this, see https://www.cplusplus.com/reference/cctype/ and https://infra.spec.whatwg.org/#code-points.
|
||||||
|
@ -151,6 +152,13 @@ constexpr u32 parse_ascii_base36_digit(u32 code_point)
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr Array<char, 36> base36_map = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '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' };
|
||||||
|
constexpr u32 to_ascii_base36_digit(u32 digit)
|
||||||
|
{
|
||||||
|
VERIFY(digit < 36);
|
||||||
|
return base36_map[digit];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using AK::is_ascii;
|
using AK::is_ascii;
|
||||||
|
@ -175,5 +183,6 @@ using AK::is_unicode_surrogate;
|
||||||
using AK::parse_ascii_base36_digit;
|
using AK::parse_ascii_base36_digit;
|
||||||
using AK::parse_ascii_digit;
|
using AK::parse_ascii_digit;
|
||||||
using AK::parse_ascii_hex_digit;
|
using AK::parse_ascii_hex_digit;
|
||||||
|
using AK::to_ascii_base36_digit;
|
||||||
using AK::to_ascii_lowercase;
|
using AK::to_ascii_lowercase;
|
||||||
using AK::to_ascii_uppercase;
|
using AK::to_ascii_uppercase;
|
||||||
|
|
Loading…
Reference in a new issue