|
@@ 5551-5562 (lines=12) @@
|
| 5548 |
|
$buf .= $cc1 . $cc2; |
| 5549 |
|
} |
| 5550 |
|
|
| 5551 |
|
} elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8 |
| 5552 |
|
|
| 5553 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5554 |
|
$buf .= $c1 . $c2 . $c3; |
| 5555 |
|
$i += 2; |
| 5556 |
|
} else { // not valid UTF8 - convert it |
| 5557 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 5558 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 5559 |
|
$buf .= $cc1 . $cc2; |
| 5560 |
|
} |
| 5561 |
|
|
| 5562 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 5563 |
|
|
| 5564 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5565 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
|
@@ 5564-5571 (lines=8) @@
|
| 5561 |
|
|
| 5562 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 5563 |
|
|
| 5564 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5565 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
| 5566 |
|
$i += 3; |
| 5567 |
|
} else { // not valid UTF8 - convert it |
| 5568 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 5569 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 5570 |
|
$buf .= $cc1 . $cc2; |
| 5571 |
|
} |
| 5572 |
|
|
| 5573 |
|
} else { // doesn't look like UTF8, but should be converted |
| 5574 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |