|
@@ 6224-6235 (lines=12) @@
|
| 6221 |
|
$buf .= $cc1 . $cc2; |
| 6222 |
|
} |
| 6223 |
|
|
| 6224 |
|
} elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8 |
| 6225 |
|
|
| 6226 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6227 |
|
$buf .= $c1 . $c2 . $c3; |
| 6228 |
|
$i += 2; |
| 6229 |
|
} else { // not valid UTF8 - convert it |
| 6230 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 6231 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 6232 |
|
$buf .= $cc1 . $cc2; |
| 6233 |
|
} |
| 6234 |
|
|
| 6235 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 6236 |
|
|
| 6237 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6238 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
|
@@ 6237-6244 (lines=8) @@
|
| 6234 |
|
|
| 6235 |
|
} elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8 |
| 6236 |
|
|
| 6237 |
|
if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already |
| 6238 |
|
$buf .= $c1 . $c2 . $c3 . $c4; |
| 6239 |
|
$i += 3; |
| 6240 |
|
} else { // not valid UTF8 - convert it |
| 6241 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 6242 |
|
$cc2 = ($c1 & "\x3f") | "\x80"; |
| 6243 |
|
$buf .= $cc1 . $cc2; |
| 6244 |
|
} |
| 6245 |
|
|
| 6246 |
|
} else { // doesn't look like UTF8, but should be converted |
| 6247 |
|
$cc1 = (chr(ord($c1) / 64) | "\xc0"); |