|
@@ 1829-1833 (lines=5) @@
|
| 1826 |
|
if ($countbytes == 0) { // get starting octect |
| 1827 |
|
if ($char <= 0x7F) { |
| 1828 |
|
return $char; // use the character "as is" because is ASCII |
| 1829 |
|
} elseif (($char >> 0x05) == 0x06) { // 2 bytes character (0x06 = 110 BIN) |
| 1830 |
|
$bytes[] = ($char - 0xC0) << 0x06; |
| 1831 |
|
++$countbytes; |
| 1832 |
|
$numbytes = 2; |
| 1833 |
|
} elseif (($char >> 0x04) == 0x0E) { // 3 bytes character (0x0E = 1110 BIN) |
| 1834 |
|
$bytes[] = ($char - 0xE0) << 0x0C; |
| 1835 |
|
++$countbytes; |
| 1836 |
|
$numbytes = 3; |
|
@@ 1837-1841 (lines=5) @@
|
| 1834 |
|
$bytes[] = ($char - 0xE0) << 0x0C; |
| 1835 |
|
++$countbytes; |
| 1836 |
|
$numbytes = 3; |
| 1837 |
|
} elseif (($char >> 0x03) == 0x1E) { // 4 bytes character (0x1E = 11110 BIN) |
| 1838 |
|
$bytes[] = ($char - 0xF0) << 0x12; |
| 1839 |
|
++$countbytes; |
| 1840 |
|
$numbytes = 4; |
| 1841 |
|
} else { |
| 1842 |
|
// use replacement character for other invalid sequences |
| 1843 |
|
return 0xFFFD; |
| 1844 |
|
} |