|
@@ 6453-6464 (lines=12) @@
|
| 6450 |
|
$buf .= $cc1 . $cc2; |
| 6451 |
|
} |
| 6452 |
|
|
| 6453 |
|
} elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8 |
| 6454 |
|
|
| 6455 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6456 |
|
$buf .= $c1 . $c2 . $c3; |
| 6457 |
|
$i += 2; |
| 6458 |
|
} else { // not valid UTF8 - convert it |
| 6459 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 6460 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 6461 |
|
$buf .= $cc1 . $cc2; |
| 6462 |
|
} |
| 6463 |
|
|
| 6464 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 6465 |
|
|
| 6466 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6467 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
|
@@ 6466-6473 (lines=8) @@
|
| 6463 |
|
|
| 6464 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 6465 |
|
|
| 6466 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6467 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
| 6468 |
|
$i += 3; |
| 6469 |
|
} else { // not valid UTF8 - convert it |
| 6470 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 6471 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 6472 |
|
$buf .= $cc1 . $cc2; |
| 6473 |
|
} |
| 6474 |
|
|
| 6475 |
|
} else { // doesn't look like UTF8, but should be converted |
| 6476 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |