ConverterUnidecode Class Reference
[Unidecode]
ASCII transliterations of unicode text. More...
Inheritance diagram for
ConverterUnidecode:
Public Member Functions |
|
decode ($value, $params=false) | |
Using "ConverterUnidecode::encode()
may be confusing, so let decode8) just do the same. |
|
encode ($value, $params=false) | |
Convert Unicode chars to ASCII
transliterals. |
|
Protected Member Functions |
|
unidecode ($value) | |
Unidecode given string (already Unicode).
|
|
unidecode_uchar ($uchar) | |
Decode a given unicde chat (two byte long).
|
Detailed Description
ASCII transliterations of unicode text.
Definition at line 8 of file unidecode.converter.php.
Member Function Documentation
ConverterUnidecode::decode | ( | $ | value, | |
$ | params = false |
|||
) |
Using "ConverterUnidecode::encode() may be confusing, so let decode8) just do the same.
Implements IConverter.
Definition at line 31 of file unidecode.converter.php.
00031 { 00032 return $this->encode($value, $params); 00033 }
ConverterUnidecode::encode | ( | $ | value, | |
$ | params = false |
|||
) |
Convert Unicode chars to ASCII transliterals.
- Parameters:
-
string $value string Encoding of $value, if different from current GyroLocale
Implements IConverter.
Definition at line 17 of file unidecode.converter.php.
00017 { 00018 // We need 00019 if (empty($params)) { 00020 $params = GyroLocale::get_charset(); 00021 } 00022 $value = String::convert($value, $params, 'UTF-16'); 00023 $value = $this->unidecode($value); 00024 00025 return $value; 00026 }
ConverterUnidecode::unidecode | ( | $ | value | ) | [protected] |
Unidecode given string (already Unicode).
Definition at line 38 of file unidecode.converter.php.
00038 { 00039 $ret = ''; 00040 foreach(unpack('n*', $value) as $uchar) { 00041 $ret .= $this->unidecode_uchar($uchar); 00042 } 00043 return $ret; 00044 }
ConverterUnidecode::unidecode_uchar | ( | $ | uchar | ) | [protected] |
Decode a given unicde chat (two byte long).
Definition at line 49 of file unidecode.converter.php.
00049 { 00050 if ($uchar <= 0x007f) { 00051 return chr($uchar); 00052 } 00053 00054 $high = $uchar >> 8; 00055 $low = $uchar & 0x00ff; 00056 00057 // Did we resolve the group already? 00058 $group = Arr::get_item(self::$groups, $high, false); 00059 if ($group === false) { 00060 // No, try to load it... 00061 $hex = substr('00' . dechex($high), -2); 00062 $file = dirname(__FILE__) . '/data/x' . $hex . '.php'; 00063 if (file_exists($file)) { 00064 include($file); 00065 $group = $data; 00066 } 00067 else { 00068 // No such group, fill with empty 00069 $group = array_fill(0, 0x100, ''); 00070 } 00071 self::$groups[$high] = $group; 00072 } 00073 00074 return Arr::get_item($group, $low, ''); 00075 }
The documentation for this class was generated from the following file:
- contributions/text.unidecode/lib/helpers/converters/unidecode.converter.php