From 2011fcff24768aeb8a2d93a8186e5199c3ca4fa1 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 6 Jun 2021 02:28:35 +0300 Subject: [PATCH] AK: Add the parse_ascii_base36_digit method This is similar to parse_ascii_hex_digit but can parse the whole A-Z range (also known as base36). --- AK/CharacterTypes.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AK/CharacterTypes.h b/AK/CharacterTypes.h index e55afb20ed..60bc83f9b9 100644 --- a/AK/CharacterTypes.h +++ b/AK/CharacterTypes.h @@ -140,6 +140,17 @@ constexpr u32 parse_ascii_hex_digit(u32 code_point) VERIFY_NOT_REACHED(); } +constexpr u32 parse_ascii_base36_digit(u32 code_point) +{ + if (is_ascii_digit(code_point)) + return parse_ascii_digit(code_point); + if (code_point >= 'A' && code_point <= 'Z') + return code_point - 'A' + 10; + if (code_point >= 'a' && code_point <= 'z') + return code_point - 'a' + 10; + VERIFY_NOT_REACHED(); +} + } using AK::is_ascii; @@ -161,6 +172,7 @@ using AK::is_unicode_control; using AK::is_unicode_noncharacter; using AK::is_unicode_scalar_value; 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_lowercase;