|
@@ 5410-5421 (lines=12) @@
|
| 5407 |
|
$buf .= $cc1 . $cc2; |
| 5408 |
|
} |
| 5409 |
|
|
| 5410 |
|
} elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8 |
| 5411 |
|
|
| 5412 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5413 |
|
$buf .= $c1 . $c2 . $c3; |
| 5414 |
|
$i += 2; |
| 5415 |
|
} else { // not valid UTF8 - convert it |
| 5416 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 5417 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 5418 |
|
$buf .= $cc1 . $cc2; |
| 5419 |
|
} |
| 5420 |
|
|
| 5421 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 5422 |
|
|
| 5423 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5424 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
|
@@ 5423-5430 (lines=8) @@
|
| 5420 |
|
|
| 5421 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 5422 |
|
|
| 5423 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5424 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
| 5425 |
|
$i += 3; |
| 5426 |
|
} else { // not valid UTF8 - convert it |
| 5427 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 5428 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 5429 |
|
$buf .= $cc1 . $cc2; |
| 5430 |
|
} |
| 5431 |
|
|
| 5432 |
|
} else { // doesn't look like UTF8, but should be converted |
| 5433 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |