<s>
Punycode	B-General_Concept
is	O
a	O
representation	O
of	O
Unicode	O
with	O
the	O
limited	O
ASCII	B-Protocol
character	I-Protocol
subset	O
used	O
for	O
Internet	O
hostnames	B-Protocol
.	O
</s>
<s>
Using	O
Punycode	B-General_Concept
,	O
host	B-Protocol
names	I-Protocol
containing	O
Unicode	O
characters	O
are	O
transcoded	O
to	O
a	O
subset	O
of	O
ASCII	B-Protocol
consisting	O
of	O
letters	O
,	O
digits	O
,	O
and	O
hyphens	O
,	O
which	O
is	O
called	O
the	O
letter	O
–	O
digit	O
–	O
hyphen	O
(	O
LDH	O
)	O
subset	O
.	O
</s>
<s>
While	O
the	O
Domain	B-Protocol
Name	I-Protocol
System	I-Protocol
(	O
DNS	B-Protocol
)	O
technically	O
supports	O
arbitrary	O
sequences	O
of	O
octets	O
in	O
domain	O
name	O
labels	O
,	O
the	O
DNS	B-Protocol
standards	O
recommend	O
the	O
use	O
of	O
the	O
LDH	O
subset	O
of	O
ASCII	B-Protocol
conventionally	O
used	O
for	O
host	B-Protocol
names	I-Protocol
,	O
and	O
require	O
that	O
string	O
comparisons	O
between	O
DNS	B-Protocol
domain	O
names	O
should	O
be	O
case-insensitive	O
.	O
</s>
<s>
The	O
Punycode	B-General_Concept
syntax	O
is	O
a	O
method	O
of	O
encoding	O
strings	O
containing	O
Unicode	O
characters	O
,	O
such	O
as	O
internationalized	B-Language
domain	I-Language
names	I-Language
(	O
IDNA	B-Language
)	O
,	O
into	O
the	O
LDH	O
subset	O
of	O
ASCII	B-Protocol
favored	O
by	O
DNS	B-Protocol
.	O
</s>
<s>
As	O
stated	O
in	O
RFC	O
3492	O
,	O
"	O
Punycode	B-General_Concept
is	O
an	O
instance	O
of	O
a	O
more	O
general	O
algorithm	O
called	O
Bootstring	B-General_Concept
,	O
which	O
allows	O
strings	O
composed	O
from	O
a	O
small	O
set	O
of	O
'	O
basic	O
 '	O
code	O
points	O
to	O
uniquely	O
represent	O
any	O
string	O
of	O
code	O
points	O
drawn	O
from	O
a	O
larger	O
set.	O
"	O
</s>
<s>
Punycode	B-General_Concept
defines	O
parameters	O
for	O
the	O
general	O
Bootstring	B-General_Concept
algorithm	O
to	O
match	O
the	O
characteristics	O
of	O
Unicode	O
text	O
.	O
</s>
<s>
This	O
section	O
demonstrates	O
the	O
procedure	O
for	O
Punycode	B-General_Concept
encoding	O
,	O
using	O
the	O
example	O
of	O
the	O
string	O
"	O
bücher	O
"	O
(	O
Bücher	O
is	O
German	O
for	O
books	O
)	O
,	O
which	O
is	O
translated	O
into	O
the	O
label	O
"	O
bcher-kva	O
"	O
.	O
</s>
<s>
First	O
,	O
all	O
ASCII	B-Protocol
characters	I-Protocol
in	O
the	O
string	O
are	O
copied	O
from	O
input	O
to	O
output	O
,	O
skipping	O
over	O
any	O
other	O
characters	O
.	O
</s>
<s>
if	O
there	O
was	O
at	O
least	O
one	O
ASCII	B-Protocol
character	I-Protocol
in	O
the	O
input	O
,	O
an	O
ASCII	B-Protocol
hyphen	O
is	O
appended	O
to	O
the	O
output	O
(	O
e.g.	O
,	O
"	O
bücher	O
"	O
→	O
"	O
bcher-	O
"	O
,	O
but	O
"	O
ü	O
"	O
→	O
""	O
)	O
.	O
</s>
<s>
Note	O
that	O
hyphens	O
are	O
themselves	O
ASCII	B-Protocol
characters	I-Protocol
.	O
</s>
<s>
It	O
marks	O
the	O
end	O
of	O
the	O
ASCII	B-Protocol
characters	I-Protocol
.	O
</s>
<s>
n	O
is	O
the	O
numeric	O
code	O
point	O
,	O
in	O
Unicode	O
,	O
of	O
the	O
non-ASCII	O
character	O
,	O
minus	O
127	O
(	O
the	O
end	O
of	O
ASCII	B-Protocol
)	O
.	O
</s>
<s>
It	O
renders	O
those	O
in	O
ASCII	B-Protocol
,	O
and	O
appends	O
the	O
result	O
to	O
the	O
output	O
string	O
.	O
</s>
<s>
The	O
ASCII	B-Protocol
rendering	O
is	O
:	O
0	O
→	O
'	O
a	O
 '	O
,	O
...	O
,	O
25	O
→	O
'	O
z	O
 '	O
,	O
26	O
→	O
'	O
0	O
 '	O
,	O
...	O
,	O
35	O
→	O
'	O
9	O
 '	O
,	O
with	O
the	O
number	O
's	O
digits	O
arranged	O
in	O
little-endian	O
order	O
.	O
</s>
<s>
To	O
prevent	O
hyphens	O
in	O
non-international	O
domain	O
names	O
from	O
triggering	O
a	O
Punycode	B-General_Concept
decoding	O
,	O
the	O
string	O
xn--	B-Language
is	O
prepended	O
to	O
Punycode	B-General_Concept
sequences	O
in	O
internationalized	B-Language
domain	I-Language
names	I-Language
.	O
</s>
<s>
This	O
is	O
called	O
ACE	O
(	O
ASCII	B-Protocol
Compatible	O
Encoding	O
)	O
.	O
</s>
<s>
Thus	O
the	O
domain	O
name	O
"	O
bücher.tld	O
"	O
would	O
be	O
represented	O
in	O
ASCII	B-Protocol
as	O
"	O
xn--bcher-kva.tld	O
"	O
.	O
</s>
<s>
The	O
decoder	O
is	O
a	O
finite-state	B-Architecture
machine	I-Architecture
with	O
two	O
state	O
variables	O
i	O
and	O
n	O
.	O
</s>
<s>
There	O
are	O
124	O
code	O
points	O
between	O
the	O
last	O
ASCII	B-Protocol
code	I-Protocol
point	O
(	O
127	O
=	O
0x7F	O
,	O
the	O
end	O
of	O
ASCII	B-Protocol
)	O
and	O
"	O
ü	O
"	O
(	O
code	O
point	O
252	O
=	O
0xFC	O
,	O
see	O
Unicode	O
's	O
Latin-1	O
Supplement	O
)	O
.	O
</s>
<s>
Punycode	B-General_Concept
uses	O
generalized	O
variable-length	O
integers	O
to	O
represent	O
these	O
values	O
.	O
</s>
<s>
Punycode	B-General_Concept
is	O
designed	O
to	O
work	O
across	O
all	O
scripts	O
,	O
and	O
to	O
be	O
self-optimizing	O
by	O
attempting	O
to	O
adapt	O
to	O
the	O
character	O
set	O
ranges	O
within	O
the	O
string	O
as	O
it	O
operates	O
.	O
</s>
<s>
It	O
is	O
optimized	O
for	O
the	O
case	O
where	O
the	O
string	O
is	O
composed	O
of	O
zero	O
or	O
more	O
ASCII	B-Protocol
characters	I-Protocol
and	O
in	O
addition	O
characters	O
from	O
only	O
one	O
other	O
script	O
system	O
,	O
but	O
will	O
cope	O
with	O
any	O
arbitrary	O
Unicode	O
string	O
.	O
</s>
<s>
Note	O
that	O
for	O
DNS	B-Protocol
use	O
,	O
the	O
domain	O
name	O
string	O
is	O
assumed	O
to	O
have	O
been	O
normalized	O
using	O
nameprep	O
and	O
(	O
for	O
top-level	O
domains	O
)	O
filtered	O
against	O
an	O
officially	O
registered	O
language	O
table	O
before	O
being	O
punycoded	O
,	O
and	O
that	O
the	O
DNS	B-Protocol
protocol	I-Protocol
sets	O
limits	O
on	O
the	O
acceptable	O
lengths	O
of	O
the	O
output	O
Punycode	B-General_Concept
string	O
.	O
</s>
<s>
The	O
following	O
table	O
shows	O
examples	O
of	O
Punycode	B-General_Concept
encodings	O
for	O
different	O
types	O
of	O
input	O
.	O
</s>
<s>
Input	O
Punycode	B-General_Concept
of	O
input	O
Description	O
of	O
input	O
The	O
empty	O
string	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
,	O
lowercase	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
,	O
uppercase	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
,	O
a	O
digit	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
,	O
a	O
hyphen	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
two	O
hyphens	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
more	O
than	O
one	O
,	O
no	O
hyphens	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
hyphen	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
with	O
spaces	O
.	O
</s>
<s>
Only	O
ASCII	B-Protocol
characters	I-Protocol
,	O
mixed	O
symbols	O
.	O
</s>
<s>
No	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
Cyrillic	O
character	O
.	O
</s>
<s>
No	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
Latin-1	O
Supplement	O
character	O
.	O
</s>
<s>
No	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
Greek	B-Language
character	I-Language
.	O
</s>
<s>
No	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
CJK	O
character	O
.	O
</s>
<s>
No	O
ASCII	B-Protocol
characters	I-Protocol
,	O
one	O
emoji	B-Application
character	O
.	O
</s>
<s>
No	O
ASCII	B-Protocol
characters	I-Protocol
,	O
more	O
than	O
one	O
character	O
.	O
</s>
<s>
Mixed	O
string	O
,	O
with	O
one	O
character	O
that	O
is	O
not	O
an	O
ASCII	B-Protocol
character	I-Protocol
.	O
</s>
<s>
Double-encoded	O
Punycode	B-General_Concept
of	O
"	O
München	O
"	O
.	O
</s>
<s>
Mixed	O
string	O
,	O
with	O
one	O
character	O
that	O
is	O
not	O
ASCII	B-Protocol
,	O
and	O
a	O
hyphen	O
.	O
</s>
<s>
Mixed	O
string	O
,	O
with	O
one	O
space	O
,	O
one	O
hyphen	O
,	O
and	O
one	O
character	O
that	O
is	O
not	O
ASCII	B-Protocol
.	O
</s>
<s>
Russian	O
,	O
without	O
ASCII	B-Protocol
.	O
</s>
<s>
Thai	O
,	O
without	O
ASCII	B-Protocol
.	O
</s>
<s>
Korean	O
,	O
without	O
ASCII	B-Protocol
.	O
</s>
<s>
Japanese	O
,	O
without	O
ASCII	B-Protocol
.	O
</s>
<s>
Japanese	O
with	O
ASCII	B-Protocol
.	O
</s>
<s>
Mixed	O
non-ASCII	O
scripts	O
(	O
Latin-1	O
Supplement	O
and	O
CJK	O
)	O
.	O
</s>
