Code Duplication    Length = 5-6 lines in 5 locations

src/voku/helper/UTF8.php 5 locations

@@ 6676-6681 (lines=6) @@
6673
          if ($c2 >= "\x80" && $c2 <= "\xBF") { // yeah, almost sure it's UTF8 already
6674
            $buf .= $c1 . $c2;
6675
            $i++;
6676
          } else { // not valid UTF8 - convert it
6677
            $cc1tmp = ord($c1) / 64;
6678
            $cc1 = UTF8NonStrict::chr($cc1tmp) | "\xC0";
6679
            $cc2 = ($c1 & "\x3F") | "\x80";
6680
            $buf .= $cc1 . $cc2;
6681
          }
6682
6683
        } elseif ($c1 >= "\xE0" && $c1 <= "\xEF") { // looks like 3 bytes UTF8
6684
@@ 6691-6696 (lines=6) @@
6688
          if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF") { // yeah, almost sure it's UTF8 already
6689
            $buf .= $c1 . $c2 . $c3;
6690
            $i += 2;
6691
          } else { // not valid UTF8 - convert it
6692
            $cc1tmp = ord($c1) / 64;
6693
            $cc1 = UTF8NonStrict::chr($cc1tmp) | "\xC0";
6694
            $cc2 = ($c1 & "\x3F") | "\x80";
6695
            $buf .= $cc1 . $cc2;
6696
          }
6697
6698
        } elseif ($c1 >= "\xF0" && $c1 <= "\xF7") { // looks like 4 bytes UTF8
6699
@@ 6707-6712 (lines=6) @@
6704
          if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF" && $c4 >= "\x80" && $c4 <= "\xBF") { // yeah, almost sure it's UTF8 already
6705
            $buf .= $c1 . $c2 . $c3 . $c4;
6706
            $i += 3;
6707
          } else { // not valid UTF8 - convert it
6708
            $cc1tmp = ord($c1) / 64;
6709
            $cc1 = UTF8NonStrict::chr($cc1tmp) | "\xC0";
6710
            $cc2 = ($c1 & "\x3F") | "\x80";
6711
            $buf .= $cc1 . $cc2;
6712
          }
6713
6714
        } else { // doesn't look like UTF8, but should be converted
6715
          $cc1tmp = ord($c1) / 64;
@@ 6714-6719 (lines=6) @@
6711
            $buf .= $cc1 . $cc2;
6712
          }
6713
6714
        } else { // doesn't look like UTF8, but should be converted
6715
          $cc1tmp = ord($c1) / 64;
6716
          $cc1 = UTF8NonStrict::chr($cc1tmp) | "\xC0";
6717
          $cc2 = ($c1 & "\x3F") | "\x80";
6718
          $buf .= $cc1 . $cc2;
6719
        }
6720
6721
      } elseif (($c1 & "\xC0") === "\x80") { // needs conversion
6722
@@ 6726-6730 (lines=5) @@
6723
        $ordC1 = ord($c1);
6724
        if (isset(self::$WIN1252_TO_UTF8[$ordC1])) { // found in Windows-1252 special cases
6725
          $buf .= self::$WIN1252_TO_UTF8[$ordC1];
6726
        } else {
6727
          $cc1 = UTF8NonStrict::chr($ordC1 / 64) | "\xC0";
6728
          $cc2 = ($c1 & "\x3F") | "\x80";
6729
          $buf .= $cc1 . $cc2;
6730
        }
6731
6732
      } else { // it doesn't need conversion
6733
        $buf .= $c1;