|
@@ 6371-6382 (lines=12) @@
|
| 6368 |
|
$buf .= $cc1 . $cc2; |
| 6369 |
|
} |
| 6370 |
|
|
| 6371 |
|
} elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8 |
| 6372 |
|
|
| 6373 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6374 |
|
$buf .= $c1 . $c2 . $c3; |
| 6375 |
|
$i += 2; |
| 6376 |
|
} else { // not valid UTF8 - convert it |
| 6377 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 6378 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 6379 |
|
$buf .= $cc1 . $cc2; |
| 6380 |
|
} |
| 6381 |
|
|
| 6382 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 6383 |
|
|
| 6384 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6385 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
|
@@ 6384-6391 (lines=8) @@
|
| 6381 |
|
|
| 6382 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 6383 |
|
|
| 6384 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6385 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
| 6386 |
|
$i += 3; |
| 6387 |
|
} else { // not valid UTF8 - convert it |
| 6388 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 6389 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 6390 |
|
$buf .= $cc1 . $cc2; |
| 6391 |
|
} |
| 6392 |
|
|
| 6393 |
|
} else { // doesn't look like UTF8, but should be converted |
| 6394 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |