Версия: 6.x
burger close
Класс IdnaConvert

Подробное описание

Encode/decode Internationalized Domain Names.

Автор
Matthias Sommerfeld mso@p.nosp@m.hlyl.nosp@m.abs.d.nosp@m.e
Версия
0.8.0 2011-03-11

Открытые члены

 __construct ($options=false)
 
 setParameter ($option, $value=false)
 
 decode ($input, $one_time_encoding=false)
 
 encode ($decoded, $one_time_encoding=false)
 
 encodeUri ($uri)
 
 getLastError ()
 

Открытые статические члены

static getInstance ($params=[])
 
static singleton ($params=[])
 

Защищенные члены

 _decode ($encoded)
 
 _encode ($decoded)
 
 _adapt ($delta, $npoints, $is_first)
 
 _encode_digit ($d)
 
 _decode_digit ($cp)
 
 _error ($error= '')
 
 _nameprep ($input)
 
 _hangul_decompose ($char)
 
 _hangul_compose ($input)
 
 _get_combining_class ($char)
 
 _apply_cannonical_ordering ($input)
 
 _combine ($input)
 
 _utf8_to_ucs4 ($input)
 
 _ucs4_to_utf8 ($input)
 
 _ucs4_to_ucs4_string ($input)
 
 _ucs4_string_to_ucs4 ($input)
 

Защищенные статические члены

static byteLength ($string)
 

Защищенные данные

 $_punycode_prefix = 'xn--'
 
 $_invalid_ucs = 0x80000000
 
 $_max_ucs = 0x10FFFF
 
 $_base = 36
 
 $_tmin = 1
 
 $_tmax = 26
 
 $_skew = 38
 
 $_damp = 700
 
 $_initial_bias = 72
 
 $_initial_n = 0x80
 
 $_sbase = 0xAC00
 
 $_lbase = 0x1100
 
 $_vbase = 0x1161
 
 $_tbase = 0x11A7
 
 $_lcount = 19
 
 $_vcount = 21
 
 $_tcount = 28
 
 $_ncount = 588
 
 $_scount = 11172
 
 $_error = false
 
 $_api_encoding = 'utf8'
 
 $_allow_overlong = false
 
 $_strict_mode = false
 
 $_idn_version = 2003
 
 $slast
 

Статические защищенные данные

static $_mb_string_overload = null
 
static $NP
 

Конструктор(ы)

__construct (   $options = false)

the constructor

Аргументы
array$options
Возвращает
boolean
Начиная с
0.5.2

Методы

_adapt (   $delta,
  $npoints,
  $is_first 
)
protected

Adapt the bias according to the current code point and position

Аргументы
int$delta
int$npoints
int$is_first
Возвращает
int
_apply_cannonical_ordering (   $input)
protected

Applies the cannonical ordering of a decomposed UCS4 sequence

Аргументы
arrayDecomposed UCS4 sequence
Возвращает
array Ordered USC4 sequence
_combine (   $input)
protected

Do composition of a sequence of starter and non-starter

Аргументы
arrayUCS4 Decomposed sequence
Возвращает
array Ordered USC4 sequence
_decode (   $encoded)
protected

The actual decoding algorithm

Аргументы
string
Возвращает
mixed
_decode_digit (   $cp)
protected

Decode a certain digit

Аргументы
int$cp
Возвращает
int
_encode (   $decoded)
protected

The actual encoding algorithm

Аргументы
string
Возвращает
mixed
_encode_digit (   $d)
protected

Encoding a certain digit

Аргументы
int$d
Возвращает
string
_error (   $error = '')
protected

Internal error handling method

Аргументы
string$error
_get_combining_class (   $char)
protected

Returns the combining class of a certain wide char

Аргументы
integerWide char to check (32bit integer)
Возвращает
integer Combining class if found, else 0
_hangul_compose (   $input)
protected

Ccomposes a Hangul syllable (see http://www.unicode.org/unicode/reports/tr15/#Hangul

Аргументы
arrayDecomposed UCS4 sequence
Возвращает
array UCS4 sequence with syllables composed
_hangul_decompose (   $char)
protected

Decomposes a Hangul syllable (see http://www.unicode.org/unicode/reports/tr15/#Hangul

Аргументы
integer32bit UCS4 code point
Возвращает
array Either Hangul Syllable decomposed or original 32bit value as one value array
_nameprep (   $input)
protected

Do Nameprep according to RFC3491 and RFC3454

Аргументы
arrayUnicode Characters
Возвращает
string Unicode Characters, Nameprep'd
_ucs4_string_to_ucs4 (   $input)
protected

Convert UCS-4 strin into UCS-4 garray

Аргументы
string$input
Возвращает
array
_ucs4_to_ucs4_string (   $input)
protected

Convert UCS-4 array into UCS-4 string

Аргументы
array$input
Возвращает
string
_ucs4_to_utf8 (   $input)
protected

Convert UCS-4 string into UTF-8 string See _utf8_to_ucs4() for details

Аргументы
string$input
Возвращает
string
_utf8_to_ucs4 (   $input)
protected

This converts an UTF-8 encoded string to its UCS-4 representation By talking about UCS-4 "strings" we mean arrays of 32bit integers representing each of the "chars". This is due to PHP not being able to handle strings with bit depth different from 8. This apllies to the reverse method _ucs4_to_utf8(), too. The following UTF-8 encodings are supported: bytes bits representation 1 7 0xxxxxxx 2 11 110xxxxx 10xxxxxx 3 16 1110xxxx 10xxxxxx 10xxxxxx 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx Each x represents a bit that can be used to store character data. The five and six byte sequences are part of Annex D of ISO/IEC 10646-1:2000

Аргументы
string$input
Возвращает
string
static byteLength (   $string)
staticprotected

Gets the length of a string in bytes even if mbstring function overloading is turned on

Аргументы
string$stringthe string for which to get the length.
Возвращает
integer the length of the string in bytes.
decode (   $input,
  $one_time_encoding = false 
)

Decode a given ACE domain name

Аргументы
stringDomain name (ACE string) [
stringDesired output encoding, see setParameter]
Возвращает
string Decoded Domain name (UTF-8 or UCS-4)
encode (   $decoded,
  $one_time_encoding = false 
)

Encode a given UTF-8 domain name

Аргументы
stringDomain name (UTF-8 or UCS-4) [
stringDesired input encoding, see setParameter]
Возвращает
string Encoded Domain name (ACE string)
encodeUri (   $uri)

Removes a weakness of encode(), which cannot properly handle URIs but instead encodes their path or query components, too.

Аргументы
string$uriExpects the URI as a UTF-8 (or ASCII) string
Возвращает
string The URI encoded to Punycode, everything but the host component is left alone
Начиная с
0.6.4
static getInstance (   $params = [])
static

Attempts to return a concrete IDNA instance.

Аргументы
array$paramsSet of paramaters
Возвращает
IdnaConvert public
getLastError ( )

Use this method to get the last error ocurred

Аргументы
void
Возвращает
string The last error, that occured
setParameter (   $option,
  $value = false 
)

Sets a new option value. Available options and values: [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8, 'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8] [overlong - Unicode does not allow unnecessarily long encodings of chars, to allow this, set this parameter to true, else to false; default is false.] [strict - true: strict mode, good for registration purposes - Causes errors on failures; false: loose mode, ideal for "wildlife" applications by silently ignoring errors and returning the original input instead

Аргументы
mixedParameter to set (string: single parameter; array of Parameter => Value pairs)
stringValue to use (if parameter 1 is a string)
Возвращает
boolean true on success, false otherwise
static singleton (   $params = [])
static

Attempts to return a concrete IDNA instance for either php4 or php5, only creating a new instance if no IDNA instance with the same parameters currently exists.

Аргументы
array$paramsSet of paramaters
Возвращает
object IdnaConvert public

Поля

$_allow_overlong = false
protected
$_api_encoding = 'utf8'
protected
$_base = 36
protected
$_damp = 700
protected
$_error = false
protected
$_idn_version = 2003
protected
$_initial_bias = 72
protected
$_initial_n = 0x80
protected
$_invalid_ucs = 0x80000000
protected
$_lbase = 0x1100
protected
$_lcount = 19
protected
$_max_ucs = 0x10FFFF
protected
$_mb_string_overload = null
staticprotected
$_ncount = 588
protected
$_punycode_prefix = 'xn--'
protected
$_sbase = 0xAC00
protected
$_scount = 11172
protected
$_skew = 38
protected
$_strict_mode = false
protected
$_tbase = 0x11A7
protected
$_tcount = 28
protected
$_tmax = 26
protected
$_tmin = 1
protected
$_vbase = 0x1161
protected
$_vcount = 21
protected
$NP
staticprotected
Инициализатор
=
['map_nothing' => [0xAD, 0x34F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B, 0x200C
,0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03, 0xFE04, 0xFE05, 0xFE06, 0xFE07
,0xFE08, 0xFE09, 0xFE0A, 0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, 0xFEFF
]

Holds all relevant mapping tables See RFC3454 for details

array

Начиная с
0.5.2
$slast
protected