20 return c ==
'\r' ||
c ==
'\n' ||
c ==
'\t';
24 return 0x101010101010101ull *
v;
27constexpr bool to_lower_ascii(
char*
input,
size_t length)
noexcept {
34 for (;
i + 7 < length;
i += 8) {
75 0, 9, 10, 0, 0, 13, 0, 0};
127 return ((
v - 0x0101010101010101) & ~(
v) & 0x8080808080808080);
160 std::array<uint8_t, 256>
result{};
161 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
162 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|'}) {
169 const char c)
noexcept {
175 std::array<uint8_t, 256>
result{};
176 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
177 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|',
'%'}) {
183 for (
size_t c = 127;
c < 255;
c++) {
192 const char c)
noexcept {
197 const char*
input,
size_t length)
noexcept {
200 for (;
i + 4 <= length;
i += 4) {
206 for (;
i < length;
i++) {
212constexpr static std::array<uint8_t, 256>
214 std::array<uint8_t, 256>
result{};
215 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
216 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|',
'%'}) {
225 for (
size_t c = 127;
c < 255;
c++) {
232contains_forbidden_domain_code_point_or_upper(
const char*
input,
233 size_t length)
noexcept {
236 for (;
i + 4 <= length;
i += 4) {
246 for (;
i < length;
i++) {
255 std::array<bool, 256>
result{};
256 for (
size_t c = 0;
c < 256;
c++) {
257 result[
c] = (
c >=
'0' &&
c <=
'9') || (
c >=
'a' &&
c <=
'z') ||
258 (
c >=
'A' &&
c <=
'Z') ||
c ==
'+' ||
c ==
'-' ||
c ==
'.';
271 return (
c >=
'0' &&
c <=
'9') || (
c >=
'A' &&
c <=
'F') ||
272 (
c >=
'a' &&
c <=
'f');
276 return (
unsigned char)
c <=
' ';
280 const char c)
noexcept {
281 return c ==
'\t' ||
c ==
'\n' ||
c ==
'\r';
285 "..",
"%2e.",
".%2e",
"%2e%2e"};
288 std::string_view
input)
noexcept {
313 memcpy(&B,
b.data(),
sizeof(B));
319 for (
size_t i = 2;
i <
input.size();
i++) {
337 std::string_view
input)
noexcept {
342 return (
c >=
'0' &&
c <=
'9') || (
c >=
'a' &&
c <=
'f');
346 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11,
347 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
348 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15};
349unsigned constexpr convert_hex_to_binary(
const char c)
noexcept {
357 return std::string(
input);
363 const char* end =
input.data() +
input.size();
371 (!is_ascii_hex_digit(
pointer[1]) ||
372 !is_ascii_hex_digit(
pointer[2])))) {
377 unsigned a = convert_hex_to_binary(
pointer[1]);
378 unsigned b = convert_hex_to_binary(
pointer[2]);
379 char c =
static_cast<char>(
a * 16 +
b);
387std::string percent_encode(
const std::string_view
input,
391 return character_sets::bit_at(character_set, c);
395 return std::string(
input);
414template <
bool append>
417 ada_log(
"percent_encode ",
input,
" to output string while ",
418 append ?
"appending" :
"overwriting");
421 return character_sets::bit_at(character_set, c);
423 ada_log(
"percent_encode done checking, moved to ",
428 ada_log(
"percent_encode encoding not needed.");
467std::string percent_encode(
const std::string_view
input,
Definitions of the character sets used by unicode functions.
Common definitions for cross-platform compiler support.
#define ADA_PUSH_DISABLE_ALL_WARNINGS
#define ADA_POP_DISABLE_WARNINGS
#define ada_really_inline
ada_really_inline bool bit_at(const uint8_t a[], const uint8_t i)
std::string to_ascii(std::string_view ut8_string)
bool contains_forbidden_domain_code_point(std::string_view ascii_string)
Includes the declarations for unicode operations.
static constexpr std::array< uint8_t, 256 > is_forbidden_domain_code_point_table
static constexpr std::array< uint8_t, 256 > is_forbidden_domain_code_point_table_or_upper
static constexpr char hex_to_binary_table[]
constexpr uint64_t broadcast(uint8_t v) noexcept
constexpr bool is_tabs_or_newline(char c) noexcept
static constexpr std::array< uint8_t, 256 > is_forbidden_host_code_point_table
static constexpr std::array< bool, 256 > is_alnum_plus_table
constexpr std::string_view table_is_double_dot_path_segment[]
tl::expected< result_type, ada::errors > result
ada_warn_unused ada::result< result_type > parse(std::string_view input, const result_type *base_url=nullptr)
Definitions for all unicode specific functions.