|
1 | | -/* auto-generated on 2023-03-28 11:03:13 -0400. Do not edit! */ |
| 1 | +/* auto-generated on 2023-04-26 14:14:42 -0400. Do not edit! */ |
2 | 2 | /* begin file src/idna.cpp */ |
3 | 3 | /* begin file src/unicode_transcoding.cpp */ |
4 | 4 |
|
5 | 5 | #include <cstdint> |
6 | 6 | #include <cstring> |
| 7 | + |
7 | 8 | namespace ada::idna { |
8 | 9 |
|
9 | 10 | size_t utf8_to_utf32(const char* buf, size_t len, char32_t* utf32_output) { |
@@ -7885,9 +7886,10 @@ const char32_t uninorms::decomposition_data[] = { |
7885 | 7886 | namespace ada::idna { |
7886 | 7887 |
|
7887 | 7888 | void normalize(std::u32string& input) { |
7888 | | - // [Normalize](https://www.unicode.org/reports/tr46/#ProcessingStepNormalize). |
7889 | | - // Normalize |
7890 | | - // the domain_name string to Unicode Normalization Form C. |
| 7889 | + /** |
| 7890 | + * Normalize the domain_name string to Unicode Normalization Form C. |
| 7891 | + * @see https://www.unicode.org/reports/tr46/#ProcessingStepNormalize |
| 7892 | + */ |
7891 | 7893 | ufal::unilib::uninorms::nfc(input); |
7892 | 7894 | } |
7893 | 7895 |
|
@@ -8115,7 +8117,6 @@ bool utf32_to_punycode(std::u32string_view input, std::string &out) { |
8115 | 8117 | } // namespace ada::idna |
8116 | 8118 | /* end file src/punycode.cpp */ |
8117 | 8119 | /* begin file src/validity.cpp */ |
8118 | | - |
8119 | 8120 | #include <algorithm> |
8120 | 8121 | #include <string_view> |
8121 | 8122 |
|
@@ -9503,18 +9504,18 @@ constexpr static uint8_t is_forbidden_domain_code_point_table[] = { |
9503 | 9504 |
|
9504 | 9505 | static_assert(sizeof(is_forbidden_domain_code_point_table) == 256); |
9505 | 9506 |
|
9506 | | -inline constexpr bool is_forbidden_domain_code_point(const char c) noexcept { |
| 9507 | +inline bool is_forbidden_domain_code_point(const char c) noexcept { |
9507 | 9508 | return is_forbidden_domain_code_point_table[uint8_t(c)]; |
9508 | 9509 | } |
9509 | 9510 |
|
9510 | | -// We return "" on error. For now. |
9511 | | -std::string from_ascii_to_ascii(std::string_view ut8_string) { |
9512 | | - static const std::string error = ""; |
9513 | | - if (std::any_of(ut8_string.begin(), ut8_string.end(), |
9514 | | - is_forbidden_domain_code_point)) { |
9515 | | - return error; |
9516 | | - } |
| 9511 | +bool contains_forbidden_domain_code_point(std::string_view view) { |
| 9512 | + return ( |
| 9513 | + std::any_of(view.begin(), view.end(), is_forbidden_domain_code_point)); |
| 9514 | +} |
9517 | 9515 |
|
| 9516 | +// We return "" on error. |
| 9517 | +static std::string from_ascii_to_ascii(std::string_view ut8_string) { |
| 9518 | + static const std::string error = ""; |
9518 | 9519 | // copy and map |
9519 | 9520 | // we could be more efficient by avoiding the copy when unnecessary. |
9520 | 9521 | std::string mapped_string = std::string(ut8_string); |
@@ -9568,7 +9569,7 @@ std::string from_ascii_to_ascii(std::string_view ut8_string) { |
9568 | 9569 | return out; |
9569 | 9570 | } |
9570 | 9571 |
|
9571 | | -// We return "" on error. For now. |
| 9572 | +// We return "" on error. |
9572 | 9573 | std::string to_ascii(std::string_view ut8_string) { |
9573 | 9574 | if (is_ascii(ut8_string)) { |
9574 | 9575 | return from_ascii_to_ascii(ut8_string); |
@@ -9655,11 +9656,6 @@ std::string to_ascii(std::string_view ut8_string) { |
9655 | 9656 | out.push_back('.'); |
9656 | 9657 | } |
9657 | 9658 | } |
9658 | | - |
9659 | | - if (std::any_of(out.begin(), out.end(), is_forbidden_domain_code_point)) { |
9660 | | - return error; |
9661 | | - } |
9662 | | - |
9663 | 9659 | return out; |
9664 | 9660 | } |
9665 | 9661 | } // namespace ada::idna |
|
0 commit comments