Ada 3.2.1
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada_idna.h
Go to the documentation of this file.
1/* auto-generated on 2025-03-08 13:17:11 -0500. Do not edit! */
2/* begin file include/idna.h */
3#ifndef ADA_IDNA_H
4#define ADA_IDNA_H
5
6/* begin file include/ada/idna/unicode_transcoding.h */
7#ifndef ADA_IDNA_UNICODE_TRANSCODING_H
8#define ADA_IDNA_UNICODE_TRANSCODING_H
9
10#include <string>
11#include <string_view>
12
13namespace ada::idna {
14
15size_t utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output);
16
17size_t utf8_length_from_utf32(const char32_t* buf, size_t len);
18
19size_t utf32_length_from_utf8(const char* buf, size_t len);
20
21size_t utf32_to_utf8(const char32_t* buf, size_t len, char* utf8_output);
22
23} // namespace ada::idna
24
25#endif // ADA_IDNA_UNICODE_TRANSCODING_H
26/* end file include/ada/idna/unicode_transcoding.h */
27/* begin file include/ada/idna/mapping.h */
28#ifndef ADA_IDNA_MAPPING_H
29#define ADA_IDNA_MAPPING_H
30
31#include <string>
32#include <string_view>
33
34namespace ada::idna {
35
36// If the input is ascii, then the mapping is just -> lower case.
37void ascii_map(char* input, size_t length);
38// Map the characters according to IDNA, returning the empty string on error.
39std::u32string map(std::u32string_view input);
40
41} // namespace ada::idna
42
43#endif
44/* end file include/ada/idna/mapping.h */
45/* begin file include/ada/idna/normalization.h */
46#ifndef ADA_IDNA_NORMALIZATION_H
47#define ADA_IDNA_NORMALIZATION_H
48
49#include <string>
50#include <string_view>
51
52namespace ada::idna {
53
54// Normalize the characters according to IDNA (Unicode Normalization Form C).
55void normalize(std::u32string& input);
56
57} // namespace ada::idna
58#endif
59/* end file include/ada/idna/normalization.h */
60/* begin file include/ada/idna/punycode.h */
61#ifndef ADA_IDNA_PUNYCODE_H
62#define ADA_IDNA_PUNYCODE_H
63
64#include <string>
65#include <string_view>
66
67namespace ada::idna {
68
69bool punycode_to_utf32(std::string_view input, std::u32string& out);
70bool verify_punycode(std::string_view input);
71bool utf32_to_punycode(std::u32string_view input, std::string& out);
72
73} // namespace ada::idna
74
75#endif // ADA_IDNA_PUNYCODE_H
76/* end file include/ada/idna/punycode.h */
77/* begin file include/ada/idna/validity.h */
78#ifndef ADA_IDNA_VALIDITY_H
79#define ADA_IDNA_VALIDITY_H
80
81#include <string>
82#include <string_view>
83
84namespace ada::idna {
85
89bool is_label_valid(std::u32string_view label);
90
91} // namespace ada::idna
92
93#endif // ADA_IDNA_VALIDITY_H
94/* end file include/ada/idna/validity.h */
95/* begin file include/ada/idna/to_ascii.h */
96#ifndef ADA_IDNA_TO_ASCII_H
97#define ADA_IDNA_TO_ASCII_H
98
99#include <string>
100#include <string_view>
101
102namespace ada::idna {
103
104// Converts a domain (e.g., www.google.com) possibly containing international
105// characters to an ascii domain (with punycode). It will not do percent
106// decoding: percent decoding should be done prior to calling this function. We
107// do not remove tabs and spaces, they should have been removed prior to calling
108// this function. We also do not trim control characters. We also assume that
109// the input is not empty. We return "" on error.
110//
111//
112// This function may accept or even produce invalid domains.
113std::string to_ascii(std::string_view ut8_string);
114
115// Returns true if the string contains a forbidden code point according to the
116// WHATGL URL specification:
117// https://url.spec.whatwg.org/#forbidden-domain-code-point
118bool contains_forbidden_domain_code_point(std::string_view ascii_string);
119
120bool constexpr is_ascii(std::u32string_view view);
121bool constexpr is_ascii(std::string_view view);
122
123} // namespace ada::idna
124
125#endif // ADA_IDNA_TO_ASCII_H
126/* end file include/ada/idna/to_ascii.h */
127/* begin file include/ada/idna/to_unicode.h */
128
129#ifndef ADA_IDNA_TO_UNICODE_H
130#define ADA_IDNA_TO_UNICODE_H
131
132#include <string_view>
133
134namespace ada::idna {
135
136std::string to_unicode(std::string_view input);
137
138} // namespace ada::idna
139
140#endif // ADA_IDNA_TO_UNICODE_H
141/* end file include/ada/idna/to_unicode.h */
142/* begin file include/ada/idna/identifier.h */
143#ifndef ADA_IDNA_IDENTIFIER_H
144#define ADA_IDNA_IDENTIFIER_H
145
146#include <string>
147#include <string_view>
148
149namespace ada::idna {
150
151// Verify if it is valid name code point given a Unicode code point and a
152// boolean first: If first is true return the result of checking if code point
153// is contained in the IdentifierStart set of code points. Otherwise return the
154// result of checking if code point is contained in the IdentifierPart set of
155// code points. Returns false if the input is empty or the code point is not
156// valid. There is minimal Unicode error handling: the input should be valid
157// UTF-8. https://urlpattern.spec.whatwg.org/#is-a-valid-name-code-point
158bool valid_name_code_point(char32_t code_point, bool first);
159
160} // namespace ada::idna
161
162#endif
163/* end file include/ada/idna/identifier.h */
164
165#endif
166/* end file include/idna.h */
void ascii_map(char *input, size_t length)
bool punycode_to_utf32(std::string_view input, std::u32string &out)
size_t utf32_length_from_utf8(const char *buf, size_t len)
Definition ada_idna.cpp:121
size_t utf32_to_utf8(const char32_t *buf, size_t len, char *utf8_output)
Definition ada_idna.cpp:130
bool constexpr is_ascii(std::u32string_view view)
void normalize(std::u32string &input)
bool utf32_to_punycode(std::u32string_view input, std::string &out)
std::string to_ascii(std::string_view ut8_string)
std::string to_unicode(std::string_view input)
bool valid_name_code_point(char32_t code_point, bool first)
size_t utf8_length_from_utf32(const char32_t *buf, size_t len)
Definition ada_idna.cpp:108
bool is_label_valid(std::u32string_view label)
bool contains_forbidden_domain_code_point(std::string_view ascii_string)
std::u32string map(std::u32string_view input)
size_t utf8_to_utf32(const char *buf, size_t len, char32_t *utf32_output)
Definition ada_idna.cpp:11
bool verify_punycode(std::string_view input)