Code Duplication    Length = 8-10 lines in 2 locations

PHPDaemon/Utils/Encoding.php 2 locations

@@ 237-246 (lines=10) @@
234
                            $cc2 = ($c1 & "\x3f") | "\x80";
235
                            $buf .= $cc1 . $cc2;
236
                        }
237
                    } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { //looks like 3 bytes UTF8
238
                        if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { //yeah, almost sure it's UTF8 already
239
                            $buf .= $c1 . $c2 . $c3;
240
                            $i = $i + 2;
241
                        } else { //not valid UTF8.  Convert it.
242
                            $cc1 = (chr(ord($c1) / 64) | "\xc0");
243
                            $cc2 = ($c1 & "\x3f") | "\x80";
244
                            $buf .= $cc1 . $cc2;
245
                        }
246
                    } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { //looks like 4 bytes UTF8
247
                        if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { //yeah, almost sure it's UTF8 already
248
                            $buf .= $c1 . $c2 . $c3;
249
                            $i = $i + 2;
@@ 247-254 (lines=8) @@
244
                            $buf .= $cc1 . $cc2;
245
                        }
246
                    } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { //looks like 4 bytes UTF8
247
                        if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { //yeah, almost sure it's UTF8 already
248
                            $buf .= $c1 . $c2 . $c3;
249
                            $i = $i + 2;
250
                        } else { //not valid UTF8.  Convert it.
251
                            $cc1 = (chr(ord($c1) / 64) | "\xc0");
252
                            $cc2 = ($c1 & "\x3f") | "\x80";
253
                            $buf .= $cc1 . $cc2;
254
                        }
255
                    } else { //doesn't look like UTF8, but should be converted
256
                        $cc1 = (chr(ord($c1) / 64) | "\xc0");
257
                        $cc2 = (($c1 & "\x3f") | "\x80");