|
@@ 5757-5768 (lines=12) @@
|
| 5754 |
|
$buf .= $cc1 . $cc2; |
| 5755 |
|
} |
| 5756 |
|
|
| 5757 |
|
} elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8 |
| 5758 |
|
|
| 5759 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5760 |
|
$buf .= $c1 . $c2 . $c3; |
| 5761 |
|
$i += 2; |
| 5762 |
|
} else { // not valid UTF8 - convert it |
| 5763 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 5764 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 5765 |
|
$buf .= $cc1 . $cc2; |
| 5766 |
|
} |
| 5767 |
|
|
| 5768 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 5769 |
|
|
| 5770 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5771 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
|
@@ 5770-5777 (lines=8) @@
|
| 5767 |
|
|
| 5768 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 5769 |
|
|
| 5770 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5771 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
| 5772 |
|
$i += 3; |
| 5773 |
|
} else { // not valid UTF8 - convert it |
| 5774 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 5775 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 5776 |
|
$buf .= $cc1 . $cc2; |
| 5777 |
|
} |
| 5778 |
|
|
| 5779 |
|
} else { // doesn't look like UTF8, but should be converted |
| 5780 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |