IdnaEncoder
in package
IDNA URL encoder
Note: Not fully compliant, as nameprep does nothing yet.
Tags
Table of Contents
Constants
- ACE_PREFIX = 'xn--'
- ACE prefix used for IDNA
- BOOTSTRAP_BASE = 36
- BOOTSTRAP_DAMP = 700
- BOOTSTRAP_INITIAL_BIAS = 72
- BOOTSTRAP_INITIAL_N = 128
- BOOTSTRAP_SKEW = 38
- BOOTSTRAP_TMAX = 26
- BOOTSTRAP_TMIN = 1
- MAX_LENGTH = 64
- Maximum length of a IDNA URL in ASCII.
Methods
- encode() : string
- Encode a hostname using Punycode
- to_ascii() : string
- Convert a UTF-8 text string to an ASCII string using Punycode
- adapt() : int|float
- Adapt the bias
- digit_to_char() : string
- Convert a digit to its respective character
- nameprep() : string
- Prepare a text string for use as an IDNA name
- utf8_to_codepoints() : array<string|int, mixed>
- Convert a UTF-8 string to a UCS-4 codepoint array
Constants
ACE_PREFIX
ACE prefix used for IDNA
public
string
ACE_PREFIX
= 'xn--'
Tags
BOOTSTRAP_BASE
public
mixed
BOOTSTRAP_BASE
= 36
BOOTSTRAP_DAMP
public
mixed
BOOTSTRAP_DAMP
= 700
BOOTSTRAP_INITIAL_BIAS
public
mixed
BOOTSTRAP_INITIAL_BIAS
= 72
BOOTSTRAP_INITIAL_N
public
mixed
BOOTSTRAP_INITIAL_N
= 128
BOOTSTRAP_SKEW
public
mixed
BOOTSTRAP_SKEW
= 38
BOOTSTRAP_TMAX
public
mixed
BOOTSTRAP_TMAX
= 26
BOOTSTRAP_TMIN
public
mixed
BOOTSTRAP_TMIN
= 1
MAX_LENGTH
Maximum length of a IDNA URL in ASCII.
public
int
MAX_LENGTH
= 64
Tags
Methods
encode()
Encode a hostname using Punycode
public
static encode(string|Stringable $hostname) : string
Parameters
- $hostname : string|Stringable
-
Hostname
Tags
Return values
string —Punycode-encoded hostname
to_ascii()
Convert a UTF-8 text string to an ASCII string using Punycode
public
static to_ascii(string $text) : string
Parameters
- $text : string
-
ASCII or UTF-8 string (max length 64 characters)
Tags
Return values
string —ASCII string
adapt()
Adapt the bias
protected
static adapt(int $delta, int $numpoints, bool $firsttime) : int|float
Parameters
- $delta : int
- $numpoints : int
- $firsttime : bool
Tags
Return values
int|float —New bias
function adapt(delta,numpoints,firsttime):
digit_to_char()
Convert a digit to its respective character
protected
static digit_to_char(int $digit) : string
Parameters
- $digit : int
-
Digit in the range 0-35
Tags
Return values
string —Single character corresponding to digit
nameprep()
Prepare a text string for use as an IDNA name
protected
static nameprep(string $text) : string
Parameters
- $text : string
-
Text to prepare.
Tags
Return values
string —Prepared string
utf8_to_codepoints()
Convert a UTF-8 string to a UCS-4 codepoint array
protected
static utf8_to_codepoints(string $input) : array<string|int, mixed>
Based on \WpOrg\Requests\Iri::replace_invalid_with_pct_encoding()
Parameters
- $input : string
-
Text to convert.
Tags
Return values
array<string|int, mixed> —Unicode code points