20 return 0x101010101010101ull *
v;
23constexpr bool to_lower_ascii(
char*
input,
size_t length)
noexcept {
30 for (;
i + 7 < length;
i += 8) {
76 0, 9, 10, 0, 0, 13, 0, 0};
133 return ((
v - 0x0101010101010101) & ~(
v) & 0x8080808080808080);
166 std::array<uint8_t, 256>
result{};
167 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
168 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|'}) {
175 const char c)
noexcept {
181 std::array<uint8_t, 256>
result{};
182 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
183 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|',
'%'}) {
189 for (
size_t c = 127;
c < 255;
c++) {
198 const char c)
noexcept {
203 const char*
input,
size_t length)
noexcept {
206 for (;
i + 4 <= length;
i += 4) {
212 for (;
i < length;
i++) {
218constexpr static std::array<uint8_t, 256>
220 std::array<uint8_t, 256>
result{};
221 for (
uint8_t c : {
'\0',
'\x09',
'\x0a',
'\x0d',
' ',
'#',
'/',
':',
'<',
222 '>',
'?',
'@',
'[',
'\\',
']',
'^',
'|',
'%'}) {
231 for (
size_t c = 127;
c < 255;
c++) {
238contains_forbidden_domain_code_point_or_upper(
const char*
input,
239 size_t length)
noexcept {
242 for (;
i + 4 <= length;
i += 4) {
252 for (;
i < length;
i++) {
261 std::array<bool, 256>
result{};
262 for (
size_t c = 0;
c < 256;
c++) {
263 if (
c >=
'0' &&
c <=
'9') {
265 }
else if (
c >=
'a' &&
c <=
'z') {
267 }
else if (
c >=
'A' &&
c <=
'Z') {
269 }
else if (
c ==
'+' ||
c ==
'-' ||
c ==
'.') {
284 return (
c >=
'0' &&
c <=
'9') || (
c >=
'A' &&
c <=
'F') ||
285 (
c >=
'a' &&
c <=
'f');
289 return (
unsigned char)
c <=
' ';
293 const char c)
noexcept {
294 return c ==
'\t' ||
c ==
'\n' ||
c ==
'\r';
298 "..",
"%2e.",
".%2e",
"%2e%2e"};
301 std::string_view
input)
noexcept {
326 memcpy(&B,
b.data(),
sizeof(B));
332 for (
size_t i = 2;
i <
input.size();
i++) {
350 std::string_view
input)
noexcept {
355 return (
c >=
'0' &&
c <=
'9') || (
c >=
'a' &&
c <=
'f');
359 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11,
360 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
361 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15};
362unsigned constexpr convert_hex_to_binary(
const char c)
noexcept {
370 return std::string(
input);
376 const char* end =
input.data() +
input.size();
384 (!is_ascii_hex_digit(
pointer[1]) ||
385 !is_ascii_hex_digit(
pointer[2])))) {
390 unsigned a = convert_hex_to_binary(
pointer[1]);
391 unsigned b = convert_hex_to_binary(
pointer[2]);
392 char c =
static_cast<char>(
a * 16 +
b);
400std::string percent_encode(
const std::string_view
input,
404 return character_sets::bit_at(character_set, c);
408 return std::string(
input);
427template <
bool append>
430 ada_log(
"percent_encode ",
input,
" to output string while ",
431 append ?
"appending" :
"overwriting");
434 return character_sets::bit_at(character_set, c);
436 ada_log(
"percent_encode done checking, moved to ",
441 ada_log(
"percent_encode encoding not needed.");
480std::string percent_encode(
const std::string_view
input,
Includes all definitions for Ada.
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)
std::string to_unicode(std::string_view input)
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 std::string_view table_is_double_dot_path_segment[]
static constexpr std::array< uint8_t, 256 > is_forbidden_host_code_point_table
static constexpr std::array< bool, 256 > is_alnum_plus_table
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.