\Punycode

Copyright (c) 2014 TrueServer B.V.

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

Summary

Methods
Properties
Constants
__construct()
encode()
decode()
No public properties found
BASE
TMIN
TMAX
SKEW
DAMP
INITIAL_BIAS
INITIAL_N
PREFIX
DELIMITER
encodePart()
decodePart()
calculateThreshold()
adapt()
listCodePoints()
charToCodePoint()
codePointToChar()
$encodeTable
$decodeTable
$encoding
N/A
No private methods found
No private properties found
N/A

Constants

BASE

BASE = 36

Bootstring parameter values.

TMIN

TMIN = 1

TMAX

TMAX = 26

SKEW

SKEW = 38

DAMP

DAMP = 700

INITIAL_BIAS

INITIAL_BIAS = 72

INITIAL_N

INITIAL_N = 128

PREFIX

PREFIX = 'xn--'

DELIMITER

DELIMITER = '-'

Properties

$encodeTable

$encodeTable : 

Encode table.

Type

$decodeTable

$decodeTable : 

Decode table.

Type

$encoding

$encoding : 

Character encoding.

Type

Methods

__construct()

__construct(string  $encoding = 'UTF-8') 

Constructor.

Parameters

string $encoding

Character encoding

encode()

encode(string  $input) : string

Encode a domain to its Punycode version.

Parameters

string $input

Domain name in Unicode to be encoded

Returns

string —

Punycode representation in ASCII

decode()

decode(string  $input) : string

Decode a Punycode domain name to its Unicode counterpart.

Parameters

string $input

Domain name in Punycode

Returns

string —

Unicode domain name

encodePart()

encodePart(string  $input) : string

Encode a part of a domain name, such as tld, to its Punycode version.

Parameters

string $input

Part of a domain name

Returns

string —

Punycode representation of a domain part

decodePart()

decodePart(string  $input) : string

Decode a part of domain name, such as tld.

Parameters

string $input

Part of a domain name

Returns

string —

Unicode domain part

calculateThreshold()

calculateThreshold(integer  $k, integer  $bias) : integer

Calculate the bias threshold to fall between TMIN and TMAX.

Parameters

integer $k
integer $bias

Returns

integer

adapt()

adapt(integer  $delta, integer  $numPoints, boolean  $firstTime) : integer

Bias adaptation.

Parameters

integer $delta
integer $numPoints
boolean $firstTime

Returns

integer

listCodePoints()

listCodePoints(string  $input) : array

List code points for a given input.

Parameters

string $input

Returns

array —

Multi-dimension array with basic, non-basic and aggregated code points

charToCodePoint()

charToCodePoint(string  $char) : integer

Convert a single or multi-byte character to its code point.

Parameters

string $char

Returns

integer

codePointToChar()

codePointToChar(integer  $code) : string

Convert a code point to its single or multi-byte character.

Parameters

integer $code

Returns

string