[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/include/inc_ext/idna_convert/ -> idna_convert.class.php (summary)

(no description)

File Size: 1605 lines (95 kb)
Included or required: 7 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

idna_convert:: (25 methods):
  __construct()
  set_parameter()
  decode()
  encode()
  encode_uri()
  get_last_error()
  _decode()
  _encode()
  _adapt()
  _encode_digit()
  _decode_digit()
  _error()
  _nameprep()
  _hangul_decompose()
  _hangul_compose()
  _get_combining_class()
  _apply_cannonical_ordering()
  _combine()
  _utf8_to_ucs4()
  _ucs4_to_utf8()
  _ucs4_to_ucs4_string()
  _ucs4_string_to_ucs4()
  byteLength()
  getInstance()
  singleton()


Class: idna_convert  - X-Ref

Encode/decode Internationalized Domain Names.

The class allows to convert internationalized domain names
(see RFC 3490 for details) as they can be used with various registries worldwide
to be translated between their original (localized) form and their encoded form
as it will be used in the DNS (Domain Name System).

The class provides two public methods, encode() and decode(), which do exactly
what you would expect them to do. You are allowed to use complete domain names,
simple strings and complete email addresses as well. That means, that you might
use any of the following notations:

- www.nörgler.com
- xn--nrgler-wxa
- xn--brse-5qa.xn--knrz-1ra.info

Unicode input might be given as either UTF-8 string, UCS-4 string or UCS-4 array.
Unicode output is available in the same formats.
You can select your preferred format via {@link set_paramter()}.

ACE input and output is always expected to be ASCII.

__construct($options = false)   X-Ref
the constructor

param: array $options
return: boolean

set_parameter($option, $value = false)   X-Ref
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

param: mixed     Parameter to set (string: single parameter; array of Parameter => Value pairs)
param: string    Value to use (if parameter 1 is a string)
return: boolean   true on success, false otherwise

decode($input, $one_time_encoding = false)   X-Ref
Decode a given ACE domain name

param: string   Domain name (ACE string)
return: string   Decoded Domain name (UTF-8 or UCS-4)

encode($decoded, $one_time_encoding = false)   X-Ref
Encode a given UTF-8 domain name

param: string   Domain name (UTF-8 or UCS-4)
return: string   Encoded Domain name (ACE string)

encode_uri($uri)   X-Ref
Removes a weakness of encode(), which cannot properly handle URIs but instead encodes their
path or query components, too.

param: string  $uri  Expects the URI as a UTF-8 (or ASCII) string
return: string  The URI encoded to Punycode, everything but the host component is left alone

get_last_error()   X-Ref
Use this method to get the last error ocurred

param: void
return: string   The last error, that occured

_decode($encoded)   X-Ref
The actual decoding algorithm

param: string
return: mixed

_encode($decoded)   X-Ref
The actual encoding algorithm

param: string
return: mixed

_adapt($delta, $npoints, $is_first)   X-Ref
Adapt the bias according to the current code point and position

param: int $delta
param: int $npoints
param: int $is_first
return: int

_encode_digit($d)   X-Ref
Encoding a certain digit

param: int $d
return: string

_decode_digit($cp)   X-Ref
Decode a certain digit

param: int $cp
return: int

_error($error = '')   X-Ref
Internal error handling method

param: string $error

_nameprep($input)   X-Ref
Do Nameprep according to RFC3491 and RFC3454

param: array    Unicode Characters
return: string   Unicode Characters, Nameprep'd

_hangul_decompose($char)   X-Ref
Decomposes a Hangul syllable
(see http://www.unicode.org/unicode/reports/tr15/#Hangul

param: integer  32bit UCS4 code point
return: array    Either Hangul Syllable decomposed or original 32bit value as one value array

_hangul_compose($input)   X-Ref
Ccomposes a Hangul syllable
(see http://www.unicode.org/unicode/reports/tr15/#Hangul

param: array    Decomposed UCS4 sequence
return: array    UCS4 sequence with syllables composed

_get_combining_class($char)   X-Ref
Returns the combining class of a certain wide char

param: integer    Wide char to check (32bit integer)
return: integer    Combining class if found, else 0

_apply_cannonical_ordering($input)   X-Ref
Applies the cannonical ordering of a decomposed UCS4 sequence

param: array      Decomposed UCS4 sequence
return: array      Ordered USC4 sequence

_combine($input)   X-Ref
Do composition of a sequence of starter and non-starter

param: array      UCS4 Decomposed sequence
return: array      Ordered USC4 sequence

_utf8_to_ucs4($input)   X-Ref
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

param: string $input
return: string

_ucs4_to_utf8($input)   X-Ref
Convert UCS-4 string into UTF-8 string
See _utf8_to_ucs4() for details

param: string  $input
return: string

_ucs4_to_ucs4_string($input)   X-Ref
Convert UCS-4 array into UCS-4 string

param: array $input
return: string

_ucs4_string_to_ucs4($input)   X-Ref
Convert UCS-4 strin into UCS-4 garray

param: string $input
return: array

byteLength($string)   X-Ref
Gets the length of a string in bytes even if mbstring function
overloading is turned on

param: string $string the string for which to get the length.
return: integer the length of the string in bytes.

getInstance($params = array()   X-Ref
Attempts to return a concrete IDNA instance.

param: array $params Set of paramaters
return: idna_convert

singleton($params = array()   X-Ref
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.

param: array $params Set of paramaters
return: object idna_convert



Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1