Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5507-5518 (lines=12) @@
5504
            $buf .= $cc1 . $cc2;
5505
          }
5506
5507
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
5508
5509
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
5510
            $buf .= $c1 . $c2 . $c3;
5511
            $i += 2;
5512
          } else { // not valid UTF8 - convert it
5513
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
5514
            $cc2 = ($c1 & "\x3f") | "\x80";
5515
            $buf .= $cc1 . $cc2;
5516
          }
5517
5518
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
5519
5520
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
5521
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 5520-5527 (lines=8) @@
5517
5518
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
5519
5520
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
5521
            $buf .= $c1 . $c2 . $c3 . $c4;
5522
            $i += 3;
5523
          } else { // not valid UTF8 - convert it
5524
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
5525
            $cc2 = ($c1 & "\x3f") | "\x80";
5526
            $buf .= $cc1 . $cc2;
5527
          }
5528
5529
        } else { // doesn't look like UTF8, but should be converted
5530
          $cc1 = (chr(ord($c1) / 64) | "\xc0");