1 <?php defined('SYSPATH') OR die('No direct access allowed.');
7 * @copyright (c) 2007 Kohana Team
8 * @copyright (c) 2005 Harry Fuecks
9 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
15 if ($ord0 >= 0 AND $ord0 <= 127)
20 if ( ! isset($chr[1]))
22 trigger_error('Short sequence - at least 2 bytes expected, only 1 seen', E_USER_WARNING);
28 if ($ord0 >= 192 AND $ord0 <= 223)
30 return ($ord0 - 192) * 64 + ($ord1 - 128);
33 if ( ! isset($chr[2]))
35 trigger_error('Short sequence - at least 3 bytes expected, only 2 seen', E_USER_WARNING);
41 if ($ord0 >= 224 AND $ord0 <= 239)
43 return ($ord0 - 224) * 4096 + ($ord1 - 128) * 64 + ($ord2 - 128);
46 if ( ! isset($chr[3]))
48 trigger_error('Short sequence - at least 4 bytes expected, only 3 seen', E_USER_WARNING);
54 if ($ord0 >= 240 AND $ord0 <= 247)
56 return ($ord0 - 240) * 262144 + ($ord1 - 128) * 4096 + ($ord2-128) * 64 + ($ord3 - 128);
59 if ( ! isset($chr[4]))
61 trigger_error('Short sequence - at least 5 bytes expected, only 4 seen', E_USER_WARNING);
67 if ($ord0 >= 248 AND $ord0 <= 251)
69 return ($ord0 - 248) * 16777216 + ($ord1-128) * 262144 + ($ord2 - 128) * 4096 + ($ord3 - 128) * 64 + ($ord4 - 128);
72 if ( ! isset($chr[5]))
74 trigger_error('Short sequence - at least 6 bytes expected, only 5 seen', E_USER_WARNING);
78 if ($ord0 >= 252 AND $ord0 <= 253)
80 return ($ord0 - 252) * 1073741824 + ($ord1 - 128) * 16777216 + ($ord2 - 128) * 262144 + ($ord3 - 128) * 4096 + ($ord4 - 128) * 64 + (ord($chr[5]) - 128);
83 if ($ord0 >= 254 AND $ord0 <= 255)
85 trigger_error('Invalid UTF-8 with surrogate ordinal '.$ord0, E_USER_WARNING);