Ada
4.1.1
Fast spec-compliant URL parser
Toggle main menu visibility
Loading...
Searching...
No Matches
to_ascii.h
Go to the documentation of this file.
1
#ifndef ADA_IDNA_TO_ASCII_H
2
#define ADA_IDNA_TO_ASCII_H
3
4
#include <string>
5
#include <string_view>
6
7
#include "
ada/idna/limits.h
"
8
9
namespace
ada::idna
{
10
11
// Converts a domain (e.g., www.google.com) possibly containing international
12
// characters to an ascii domain (with punycode). It will not do percent
13
// decoding: percent decoding should be done prior to calling this function. We
14
// do not remove tabs and spaces, they should have been removed prior to calling
15
// this function. We also do not trim control characters. We also assume that
16
// the input is not empty. We return "" on error. Non-ASCII inputs longer than
17
// max_domain_input_bytes are rejected; ASCII inputs of any length are accepted
18
// (they are only lowercased).
19
//
20
// This function may accept or even produce invalid domains (WHATWG carve-outs).
21
std::string
to_ascii
(std::string_view ut8_string);
22
23
// Same as to_ascii, but writes into `out` and returns false on error without
24
// relying on empty-string ambiguity.
25
[[nodiscard]]
bool
to_ascii
(std::string_view ut8_string, std::string& out);
26
27
// Returns true if the string contains a forbidden code point according to the
28
// WHATGL URL specification:
29
// https://url.spec.whatwg.org/#forbidden-domain-code-point
30
bool
contains_forbidden_domain_code_point
(std::string_view ascii_string);
31
32
bool
constexpr
is_ascii
(std::u32string_view view);
33
bool
constexpr
is_ascii
(std::string_view view);
34
35
}
// namespace ada::idna
36
37
#endif
// ADA_IDNA_TO_ASCII_H
limits.h
ada::idna
Definition
identifier.h:7
ada::idna::is_ascii
bool constexpr is_ascii(std::u32string_view view)
Definition
ada_idna.cpp:6444
ada::idna::to_ascii
std::string to_ascii(std::string_view ut8_string)
Definition
ada_idna.cpp:6695
ada::idna::contains_forbidden_domain_code_point
bool contains_forbidden_domain_code_point(std::string_view ascii_string)
Definition
ada_idna.cpp:6481