Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
punycode.h
1#ifndef SOURCEMETA_CORE_PUNYCODE_H_
2#define SOURCEMETA_CORE_PUNYCODE_H_
3
4#ifndef SOURCEMETA_CORE_PUNYCODE_EXPORT
5#include <sourcemeta/core/punycode_export.h>
6#endif
7
8// NOLINTBEGIN(misc-include-cleaner)
9#include <sourcemeta/core/punycode_error.h>
10// NOLINTEND(misc-include-cleaner)
11
12#include <cstddef> // std::size_t
13#include <cstdint> // std::uint32_t
14#include <istream> // std::istream
15#include <limits> // std::numeric_limits
16#include <ostream> // std::ostream
17#include <string> // std::string, std::u32string
18#include <string_view> // std::string_view, std::u32string_view
19
28
29namespace sourcemeta::core {
30
31// See https://www.rfc-editor.org/rfc/rfc3492
32
38inline constexpr std::size_t PUNYCODE_MAXIMUM_CODE_POINTS{
39 std::numeric_limits<std::uint32_t>::max()};
40
45inline constexpr std::size_t PUNYCODE_MAXIMUM_ENCODED_BYTES{
46 std::numeric_limits<std::uint32_t>::max()};
47
68SOURCEMETA_CORE_PUNYCODE_EXPORT
69auto utf32_to_punycode(std::u32string_view input,
70 std::size_t maximum_code_points =
71 PUNYCODE_MAXIMUM_CODE_POINTS) -> std::string;
72
88SOURCEMETA_CORE_PUNYCODE_EXPORT
90 std::istream &input, std::ostream &output,
91 std::size_t maximum_code_points = PUNYCODE_MAXIMUM_CODE_POINTS) -> void;
92
105SOURCEMETA_CORE_PUNYCODE_EXPORT
106auto utf8_to_punycode(const std::string_view input,
107 std::size_t maximum_code_points =
108 PUNYCODE_MAXIMUM_CODE_POINTS) -> std::string;
109
131SOURCEMETA_CORE_PUNYCODE_EXPORT
132auto punycode_to_utf32(const std::string_view input,
133 std::size_t maximum_encoded_bytes =
134 PUNYCODE_MAXIMUM_ENCODED_BYTES) -> std::u32string;
135
151SOURCEMETA_CORE_PUNYCODE_EXPORT
153 std::istream &input, std::ostream &output,
154 std::size_t maximum_encoded_bytes = PUNYCODE_MAXIMUM_ENCODED_BYTES) -> void;
155
168SOURCEMETA_CORE_PUNYCODE_EXPORT
169auto punycode_to_utf8(const std::string_view input,
170 std::size_t maximum_encoded_bytes =
171 PUNYCODE_MAXIMUM_ENCODED_BYTES) -> std::string;
172
173} // namespace sourcemeta::core
174
175#endif
SOURCEMETA_CORE_PUNYCODE_EXPORT auto utf32_to_punycode(std::u32string_view input, std::size_t maximum_code_points=PUNYCODE_MAXIMUM_CODE_POINTS) -> std::string
SOURCEMETA_CORE_PUNYCODE_EXPORT auto punycode_to_utf8(std::istream &input, std::ostream &output, std::size_t maximum_encoded_bytes=PUNYCODE_MAXIMUM_ENCODED_BYTES) -> void
constexpr std::size_t PUNYCODE_MAXIMUM_ENCODED_BYTES
Definition punycode.h:45
constexpr std::size_t PUNYCODE_MAXIMUM_CODE_POINTS
Definition punycode.h:38
SOURCEMETA_CORE_PUNYCODE_EXPORT auto punycode_to_utf32(const std::string_view input, std::size_t maximum_encoded_bytes=PUNYCODE_MAXIMUM_ENCODED_BYTES) -> std::u32string
SOURCEMETA_CORE_PUNYCODE_EXPORT auto utf8_to_punycode(std::istream &input, std::ostream &output, std::size_t maximum_code_points=PUNYCODE_MAXIMUM_CODE_POINTS) -> void