API / Minn\Http / Punycode

Punycode final class

Minn\Http\Punycode · public/minn/src/Minn/Http/Punycode.php · 103 lines

Internationalized host names in ASCII: each label that is not ASCII is written as "xn--" plus its Punycode (RFC 3492) and must stay under 64 bytes. Labels keep their case: there is no Nameprep step, as on the reference ("Bücher" becomes "xn--Bcher-kva").

Uses 1

Constants and properties

constPREFIX = 'xn--'
constMAX_LENGTH = 64
privateBASE = 36
privateTMIN = 1
privateTMAX = 26
privateSKEW = 38
privateDAMP = 700
privateINITIAL_BIAS = 72
privateINITIAL_N = 128

Public

statichost(string $hostname): string#

A whole host name, label by label.

staticlabel(string $text): string#

One label in ASCII.

staticencode(string $input): string#

The Punycode of a UTF-8 string (without the prefix).

Internals 3

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatedigits(int $q, int $bias): string#

One delta as variable-length digits.

privatedigit(int $d): string#
privateadapt(int $delta, int $points, int $damp): int#

The next bias; the first delta is damped by DAMP, later ones by 2.