|
@@ 5969-5980 (lines=12) @@
|
| 5966 |
|
$buf .= $cc1 . $cc2; |
| 5967 |
|
} |
| 5968 |
|
|
| 5969 |
|
} elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8 |
| 5970 |
|
|
| 5971 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5972 |
|
$buf .= $c1 . $c2 . $c3; |
| 5973 |
|
$i += 2; |
| 5974 |
|
} else { // not valid UTF8 - convert it |
| 5975 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 5976 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 5977 |
|
$buf .= $cc1 . $cc2; |
| 5978 |
|
} |
| 5979 |
|
|
| 5980 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 5981 |
|
|
| 5982 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5983 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
|
@@ 5982-5989 (lines=8) @@
|
| 5979 |
|
|
| 5980 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 5981 |
|
|
| 5982 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 5983 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
| 5984 |
|
$i += 3; |
| 5985 |
|
} else { // not valid UTF8 - convert it |
| 5986 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 5987 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 5988 |
|
$buf .= $cc1 . $cc2; |
| 5989 |
|
} |
| 5990 |
|
|
| 5991 |
|
} else { // doesn't look like UTF8, but should be converted |
| 5992 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |