AK: Add the to_ascii_base36_digit helper method

This commit is contained in:
Idan Horowitz 2021-06-29 17:50:22 +03:00 committed by Linus Groh
parent 12e66de410
commit 4a2a084789
Notes: sideshowbarker 2024-07-18 11:20:53 +09:00

View file

@ -6,6 +6,7 @@
#pragma once
#include <AK/Array.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.
@ -151,6 +152,13 @@ constexpr u32 parse_ascii_base36_digit(u32 code_point)
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;
@ -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;