IDNA URL encoder

Note: Not fully compliant, as nameprep does nothing yet.

package Requests
subpackage Utilities
see IDNA specification
see Punycode/Bootstrap specification

 Methods

Encode a hostname using Punycode

encode(string $string) : string
Static

Parameters

$string

string

Hostname

Returns

stringPunycode-encoded hostname

Convert a UTF-8 string to an ASCII string using Punycode

to_ascii(string $string) : string
Static

Parameters

$string

string

ASCII or UTF-8 string (max length 64 characters)

Exceptions

\Requests_Exception Provided string longer than 64 ASCII characters (`idna.provided_too_long`)
\Requests_Exception Prepared string longer than 64 ASCII characters (`idna.prepared_too_long`)
\Requests_Exception Provided string already begins with xn-- (`idna.provided_is_prefixed`)
\Requests_Exception Encoded string longer than 64 ASCII characters (`idna.encoded_too_long`)

Returns

stringASCII string

Adapt the bias

adapt(integer $delta, integer $numpoints, boolean $firsttime) : integer
Static
see

Parameters

$delta

integer

$numpoints

integer

$firsttime

boolean

Returns

integerNew bias

Convert a digit to its respective character

digit_to_char(integer $digit) : string
Static
see

Parameters

$digit

integer

Digit in the range 0-35

Exceptions

\Requests_Exception On invalid digit (`idna.invalid_digit`)

Returns

stringSingle character corresponding to digit

Prepare a string for use as an IDNA name

nameprep(string $string) : string
Static
todo Implement this based on RFC 3491 and the newer 5891

Parameters

$string

string

Returns

stringPrepared string

Convert a UTF-8 string to a UCS-4 codepoint array

utf8_to_codepoints(string $input) : array
Static

Based on Requests_IRI::replace_invalid_with_pct_encoding()

Parameters

$input

string

Exceptions

\Requests_Exception Invalid UTF-8 codepoint (`idna.invalidcodepoint`)

Returns

arrayUnicode code points

 Constants

 

ACE prefix used for IDNA

ACE_PREFIX = 'xn--' : string
see
 

BOOTSTRAP_BASE

BOOTSTRAP_BASE = 36 
 

BOOTSTRAP_DAMP

BOOTSTRAP_DAMP = 700 
 

BOOTSTRAP_INITIAL_BIAS

BOOTSTRAP_INITIAL_BIAS = 72 
 

BOOTSTRAP_INITIAL_N

BOOTSTRAP_INITIAL_N = 128 
 

BOOTSTRAP_SKEW

BOOTSTRAP_SKEW = 38 
 

BOOTSTRAP_TMAX

BOOTSTRAP_TMAX = 26 
 

BOOTSTRAP_TMIN

BOOTSTRAP_TMIN = 1