Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6597-6608 (lines=12) @@
6594
            $buf .= $cc1 . $cc2;
6595
          }
6596
6597
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6598
6599
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6600
            $buf .= $c1 . $c2 . $c3;
6601
            $i += 2;
6602
          } else { // not valid UTF8 - convert it
6603
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6604
            $cc2 = ($c1 & "\x3f") | "\x80";
6605
            $buf .= $cc1 . $cc2;
6606
          }
6607
6608
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6609
6610
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6611
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 6610-6617 (lines=8) @@
6607
6608
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6609
6610
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6611
            $buf .= $c1 . $c2 . $c3 . $c4;
6612
            $i += 3;
6613
          } else { // not valid UTF8 - convert it
6614
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6615
            $cc2 = ($c1 & "\x3f") | "\x80";
6616
            $buf .= $cc1 . $cc2;
6617
          }
6618
6619
        } else { // doesn't look like UTF8, but should be converted
6620
          $cc1 = (chr(ord($c1) / 64) | "\xc0");