PHP Class Punycode

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Punycode implementation as described in RFC 3492
See also: https://github.com/true/php-punycode
Exibir arquivo Open project: zblogcn/zblogphp Class Usage Examples

Protected Properties

Property Type Description
$decodeTable Decode table
$encodeTable Encode table
$encoding Character encoding

Public Methods

Method Description
__construct ( string $encoding = 'UTF-8' ) Constructor
decode ( string $input ) : string Decode a Punycode domain name to its Unicode counterpart
encode ( string $input ) : string Encode a domain to its Punycode version

Protected Methods

Method Description
adapt ( integer $delta, integer $numPoints, boolean $firstTime ) : integer Bias adaptation
calculateThreshold ( integer $k, integer $bias ) : integer Calculate the bias threshold to fall between TMIN and TMAX
charToCodePoint ( string $char ) : integer Convert a single or multi-byte character to its code point
codePointToChar ( integer $code ) : string Convert a code point to its single or multi-byte character
decodePart ( string $input ) : string Decode a part of domain name, such as tld
encodePart ( string $input ) : string Encode a part of a domain name, such as tld, to its Punycode version
listCodePoints ( string $input ) : array List code points for a given input

Method Details

__construct() public method

Constructor
public __construct ( string $encoding = 'UTF-8' )
$encoding string Character encoding

adapt() protected method

Bias adaptation
protected adapt ( integer $delta, integer $numPoints, boolean $firstTime ) : integer
$delta integer
$numPoints integer
$firstTime boolean
return integer

calculateThreshold() protected method

Calculate the bias threshold to fall between TMIN and TMAX
protected calculateThreshold ( integer $k, integer $bias ) : integer
$k integer
$bias integer
return integer

charToCodePoint() protected method

Convert a single or multi-byte character to its code point
protected charToCodePoint ( string $char ) : integer
$char string
return integer

codePointToChar() protected method

Convert a code point to its single or multi-byte character
protected codePointToChar ( integer $code ) : string
$code integer
return string

decode() public method

Decode a Punycode domain name to its Unicode counterpart
public decode ( string $input ) : string
$input string Domain name in Punycode
return string Unicode domain name

decodePart() protected method

Decode a part of domain name, such as tld
protected decodePart ( string $input ) : string
$input string Part of a domain name
return string Unicode domain part

encode() public method

Encode a domain to its Punycode version
public encode ( string $input ) : string
$input string Domain name in Unicode to be encoded
return string Punycode representation in ASCII

encodePart() protected method

Encode a part of a domain name, such as tld, to its Punycode version
protected encodePart ( string $input ) : string
$input string Part of a domain name
return string Punycode representation of a domain part

listCodePoints() protected method

List code points for a given input
protected listCodePoints ( string $input ) : array
$input string
return array Multi-dimension array with basic, non-basic and aggregated code points

Property Details

$decodeTable protected_oe static_oe property

Decode table
protected static $decodeTable

$encodeTable protected_oe static_oe property

Encode table
protected static $encodeTable

$encoding protected_oe property

Character encoding
protected $encoding