diff --git a/AK/CharacterTypes.h b/AK/CharacterTypes.h index 60bc83f9b93..76fed399330 100644 --- a/AK/CharacterTypes.h +++ b/AK/CharacterTypes.h @@ -6,6 +6,7 @@ #pragma once +#include #include // 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(); } +static constexpr Array 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; @@ -175,5 +183,6 @@ using AK::is_unicode_surrogate; using AK::parse_ascii_base36_digit; using AK::parse_ascii_digit; using AK::parse_ascii_hex_digit; +using AK::to_ascii_base36_digit; using AK::to_ascii_lowercase; using AK::to_ascii_uppercase;