Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6408-6419 (lines=12) @@
6405
            $buf .= $cc1 . $cc2;
6406
          }
6407
6408
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6409
6410
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6411
            $buf .= $c1 . $c2 . $c3;
6412
            $i += 2;
6413
          } else { // not valid UTF8 - convert it
6414
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6415
            $cc2 = ($c1 & "\x3f") | "\x80";
6416
            $buf .= $cc1 . $cc2;
6417
          }
6418
6419
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6420
6421
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6422
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 6421-6428 (lines=8) @@
6418
6419
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6420
6421
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6422
            $buf .= $c1 . $c2 . $c3 . $c4;
6423
            $i += 3;
6424
          } else { // not valid UTF8 - convert it
6425
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6426
            $cc2 = ($c1 & "\x3f") | "\x80";
6427
            $buf .= $cc1 . $cc2;
6428
          }
6429
6430
        } else { // doesn't look like UTF8, but should be converted
6431
          $cc1 = (chr(ord($c1) / 64) | "\xc0");