1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//! Encoding.
use crate*;
/// Punycode encode, in-place if possible.
///
/// Please note that, per [Appendix C of RFC 3492](https://datatracker.ietf.org/doc/html/rfc3492#appendix-C), this uses [`usize`]s instead of [`u32`]s.
///
/// In practice this means nothing but someone's going to complain so I figured I'd explain myself early.
/// # Examples
/// ```
/// use better_url::util::*;
///
/// assert_eq!(encode_punycode("" ), "" );
/// assert_eq!(encode_punycode("a" ), "a-" );
/// assert_eq!(encode_punycode("a-"), "a--");
///
/// assert_eq!(encode_punycode("ليهمابتكلموشعربي؟" ), "egbpdaj6bu4bxfgehfvwxn" );
/// assert_eq!(encode_punycode("他们为什么不说中文" ), "ihqwcrb4cv8a8dqg056pqjye" );
/// assert_eq!(encode_punycode("他們爲什麽不說中文" ), "ihqwctvzc91f659drss3x8bo0yb" );
/// assert_eq!(encode_punycode("Pročprostěnemluvíčesky" ), "Proprostnemluvesky-uyb24dma41a" );
/// assert_eq!(encode_punycode("למההםפשוטלאמדבריםעברית" ), "4dbcagdahymbxekheh6e0a7fei0b" );
/// assert_eq!(encode_punycode("यहलोगहिन\u{94d}दीक\u{94d}यो\u{902}नही\u{902}बोलसकत\u{947}ह\u{948}\u{902}"), "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd" );
/// assert_eq!(encode_punycode("なぜみんな日本語を話してくれないのか" ), "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa" );
/// assert_eq!(encode_punycode("세계의모든사람들이한국어를이해한다면얼마나좋을까" ), "989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c");
/// assert_eq!(encode_punycode("почемужеонинеговорятпорусски" ), "b1abfaaepdrnnbgefbadotcwatmq2g4l" );
/// assert_eq!(encode_punycode("PorquénopuedensimplementehablarenEspañol" ), "PorqunopuedensimplementehablarenEspaol-fmd56a" );
/// assert_eq!(encode_punycode("TạisaohọkhôngthểchỉnóitiếngViệt" ), "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g" );
/// ```
/// Punycode encode into a [`String`].
///
/// Please note that, per [Appendix C of RFC 3492](https://datatracker.ietf.org/doc/html/rfc3492#appendix-C), this uses [`usize`]s instead of [`u32`]s.
///
/// In practice this means nothing but someone's going to complain so I figured I'd explain myself early.
/// Punycode encode into a [`Vec`] of bytes.
///
/// Please note that, per [Appendix C of RFC 3492](https://datatracker.ietf.org/doc/html/rfc3492#appendix-C), this uses [`usize`]s instead of [`u32`]s.
///
/// In practice this means nothing but someone's going to complain so I figured I'd explain myself early.