Documentation

Converter
in package

FinalYes
Tags
see
https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/uidna_8h.html

Table of Contents

Constants

MAX_DOMAIN_LENGTH  = 253
MAX_LABEL_LENGTH  = 63
REGEXP_IDNA_PATTERN  = '/[^\x20-\x7f]/'
REGEXP_REGISTERED_NAME  = '/ (?(DEFINE) (?<unreserved>[a-z0-9_~\-]) # . is missing as it is used to separate labels (?<sub_delims>[!$&\'()*+,;=]) (?<encoded>%[A-F0-9]{2}) (?<reg_name>(?:(?&unreserved)|(?&sub_delims)|(?&encoded))*) ) ^(?:(?&reg_name)\.)*(?&reg_name)\.?$ /ix'
General registered name regular expression.

Methods

isIdn()  : bool
Tells whether the submitted host is a valid IDN regardless of its format.
toAscii()  : Result
Converts the input to its IDNA ASCII form.
toAsciiOrFail()  : string
Converts the input to its IDNA ASCII form or throw on failure.
toUnicode()  : Result
Converts the input to its IDNA UNICODE form.
toUnicodeOrFail()  : string
Converts the input to its IDNA UNICODE form or throw on failure.
validateDomainAndLabelLength()  : int
Adapted from https://github.com/TRowbotham/idna.

Constants

MAX_DOMAIN_LENGTH

private mixed MAX_DOMAIN_LENGTH = 253

MAX_LABEL_LENGTH

private mixed MAX_LABEL_LENGTH = 63

REGEXP_IDNA_PATTERN

private mixed REGEXP_IDNA_PATTERN = '/[^\x20-\x7f]/'

REGEXP_REGISTERED_NAME

General registered name regular expression.

private mixed REGEXP_REGISTERED_NAME = '/ (?(DEFINE) (?<unreserved>[a-z0-9_~\-]) # . is missing as it is used to separate labels (?<sub_delims>[!$&\'()*+,;=]) (?<encoded>%[A-F0-9]{2}) (?<reg_name>(?:(?&unreserved)|(?&sub_delims)|(?&encoded))*) ) ^(?:(?&reg_name)\.)*(?&reg_name)\.?$ /ix'
Tags
see
https://tools.ietf.org/html/rfc3986#section-3.2.2
see
https://regex101.com/r/fptU8V/1

Methods

isIdn()

Tells whether the submitted host is a valid IDN regardless of its format.

public static isIdn(Stringable|string|null $domain) : bool

Returns false if the host is invalid or if its conversion yields the same result

Parameters
$domain : Stringable|string|null
Return values
bool

toAscii()

Converts the input to its IDNA ASCII form.

public static toAscii(Stringable|string $domain[, Option|int|null $options = null ]) : Result

This method returns the string converted to IDN ASCII form

Parameters
$domain : Stringable|string
$options : Option|int|null = null
Tags
throws
SyntaxError

if the string cannot be converted to ASCII using IDN UTS46 algorithm

Return values
Result

toAsciiOrFail()

Converts the input to its IDNA ASCII form or throw on failure.

public static toAsciiOrFail(Stringable|string $domain[, Option|int|null $options = null ]) : string
Parameters
$domain : Stringable|string
$options : Option|int|null = null
Tags
see
Converter::toAscii()
throws
SyntaxError

if the string cannot be converted to UNICODE using IDN UTS46 algorithm

throws
ConversionFailed

if the conversion returns error

Return values
string

toUnicode()

Converts the input to its IDNA UNICODE form.

public static toUnicode(Stringable|string $domain[, Option|int|null $options = null ]) : Result

This method returns the string converted to IDN UNICODE form

Parameters
$domain : Stringable|string
$options : Option|int|null = null
Tags
throws
SyntaxError

if the string cannot be converted to UNICODE using IDN UTS46 algorithm

Return values
Result

        
On this page

Search results