|
@@ 6201-6212 (lines=12) @@
|
| 6198 |
|
$buf .= $cc1 . $cc2; |
| 6199 |
|
} |
| 6200 |
|
|
| 6201 |
|
} elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8 |
| 6202 |
|
|
| 6203 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6204 |
|
$buf .= $c1 . $c2 . $c3; |
| 6205 |
|
$i += 2; |
| 6206 |
|
} else { // not valid UTF8 - convert it |
| 6207 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 6208 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 6209 |
|
$buf .= $cc1 . $cc2; |
| 6210 |
|
} |
| 6211 |
|
|
| 6212 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 6213 |
|
|
| 6214 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6215 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
|
@@ 6214-6221 (lines=8) @@
|
| 6211 |
|
|
| 6212 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 6213 |
|
|
| 6214 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6215 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
| 6216 |
|
$i += 3; |
| 6217 |
|
} else { // not valid UTF8 - convert it |
| 6218 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 6219 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 6220 |
|
$buf .= $cc1 . $cc2; |
| 6221 |
|
} |
| 6222 |
|
|
| 6223 |
|
} else { // doesn't look like UTF8, but should be converted |
| 6224 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |