Ada 2.9.2
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada_idna.h
Go to the documentation of this file.
1/* auto-generated on 2024-09-03 10:55:13 -0400. 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// check whether an ascii string needs mapping
39bool ascii_has_upper_case(char* input, size_t length);
40// Map the characters according to IDNA, returning the empty string on error.
41std::u32string map(std::u32string_view input);
42
43} // namespace ada::idna
44
45#endif
46/* end file include/ada/idna/mapping.h */
47/* begin file include/ada/idna/normalization.h */
48#ifndef ADA_IDNA_NORMALIZATION_H
49#define ADA_IDNA_NORMALIZATION_H
50
51#include <string>
52#include <string_view>
53
54namespace ada::idna {
55
56// Normalize the characters according to IDNA (Unicode Normalization Form C).
57void normalize(std::u32string& input);
58
59} // namespace ada::idna
60#endif
61/* end file include/ada/idna/normalization.h */
62/* begin file include/ada/idna/punycode.h */
63#ifndef ADA_IDNA_PUNYCODE_H
64#define ADA_IDNA_PUNYCODE_H
65
66#include <string>
67#include <string_view>
68
69namespace ada::idna {
70
71bool punycode_to_utf32(std::string_view input, std::u32string& out);
72bool verify_punycode(std::string_view input);
73bool utf32_to_punycode(std::u32string_view input, std::string& out);
74
75} // namespace ada::idna
76
77#endif // ADA_IDNA_PUNYCODE_H
78/* end file include/ada/idna/punycode.h */
79/* begin file include/ada/idna/validity.h */
80#ifndef ADA_IDNA_VALIDITY_H
81#define ADA_IDNA_VALIDITY_H
82
83#include <string>
84#include <string_view>
85
86namespace ada::idna {
87
91bool is_label_valid(std::u32string_view label);
92
93} // namespace ada::idna
94
95#endif // ADA_IDNA_VALIDITY_H
96/* end file include/ada/idna/validity.h */
97/* begin file include/ada/idna/to_ascii.h */
98#ifndef ADA_IDNA_TO_ASCII_H
99#define ADA_IDNA_TO_ASCII_H
100
101#include <string>
102#include <string_view>
103
104namespace ada::idna {
105
106// Converts a domain (e.g., www.google.com) possibly containing international
107// characters to an ascii domain (with punycode). It will not do percent
108// decoding: percent decoding should be done prior to calling this function. We
109// do not remove tabs and spaces, they should have been removed prior to calling
110// this function. We also do not trim control characters. We also assume that
111// the input is not empty. We return "" on error.
112//
113//
114// This function may accept or even produce invalid domains.
115std::string to_ascii(std::string_view ut8_string);
116
117// Returns true if the string contains a forbidden code point according to the
118// WHATGL URL specification:
119// https://url.spec.whatwg.org/#forbidden-domain-code-point
120bool contains_forbidden_domain_code_point(std::string_view ascii_string);
121
122bool constexpr is_ascii(std::u32string_view view);
123bool constexpr is_ascii(std::string_view view);
124
125} // namespace ada::idna
126
127#endif // ADA_IDNA_TO_ASCII_H
128/* end file include/ada/idna/to_ascii.h */
129/* begin file include/ada/idna/to_unicode.h */
130
131#ifndef ADA_IDNA_TO_UNICODE_H
132#define ADA_IDNA_TO_UNICODE_H
133
134#include <string_view>
135
136namespace ada::idna {
137
138std::string to_unicode(std::string_view input);
139
140} // namespace ada::idna
141
142#endif // ADA_IDNA_TO_UNICODE_H
143/* end file include/ada/idna/to_unicode.h */
144
145#endif
146/* 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)
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 ascii_has_upper_case(char *input, size_t length)
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)