Code Duplication    Length = 5-6 lines in 5 locations

src/voku/helper/UTF8.php 5 locations

@@ 6872-6877 (lines=6) @@
6869
          if ($c2 >= "\x80" && $c2 <= "\xBF") { // yeah, almost sure it's UTF8 already
6870
            $buf .= $c1 . $c2;
6871
            $i++;
6872
          } else { // not valid UTF8 - convert it
6873
            $cc1tmp = ord($c1) / 64;
6874
            $cc1 = self::chr_and_parse_int($cc1tmp) | "\xC0";
6875
            $cc2 = ($c1 & "\x3F") | "\x80";
6876
            $buf .= $cc1 . $cc2;
6877
          }
6878
6879
        } elseif ($c1 >= "\xE0" && $c1 <= "\xEF") { // looks like 3 bytes UTF8
6880
@@ 6887-6892 (lines=6) @@
6884
          if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF") { // yeah, almost sure it's UTF8 already
6885
            $buf .= $c1 . $c2 . $c3;
6886
            $i += 2;
6887
          } else { // not valid UTF8 - convert it
6888
            $cc1tmp = ord($c1) / 64;
6889
            $cc1 = self::chr_and_parse_int($cc1tmp) | "\xC0";
6890
            $cc2 = ($c1 & "\x3F") | "\x80";
6891
            $buf .= $cc1 . $cc2;
6892
          }
6893
6894
        } elseif ($c1 >= "\xF0" && $c1 <= "\xF7") { // looks like 4 bytes UTF8
6895
@@ 6903-6908 (lines=6) @@
6900
          if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF" && $c4 >= "\x80" && $c4 <= "\xBF") { // yeah, almost sure it's UTF8 already
6901
            $buf .= $c1 . $c2 . $c3 . $c4;
6902
            $i += 3;
6903
          } else { // not valid UTF8 - convert it
6904
            $cc1tmp = ord($c1) / 64;
6905
            $cc1 = self::chr_and_parse_int($cc1tmp) | "\xC0";
6906
            $cc2 = ($c1 & "\x3F") | "\x80";
6907
            $buf .= $cc1 . $cc2;
6908
          }
6909
6910
        } else { // doesn't look like UTF8, but should be converted
6911
          $cc1tmp = ord($c1) / 64;
@@ 6910-6915 (lines=6) @@
6907
            $buf .= $cc1 . $cc2;
6908
          }
6909
6910
        } else { // doesn't look like UTF8, but should be converted
6911
          $cc1tmp = ord($c1) / 64;
6912
          $cc1 = self::chr_and_parse_int($cc1tmp) | "\xC0";
6913
          $cc2 = ($c1 & "\x3F") | "\x80";
6914
          $buf .= $cc1 . $cc2;
6915
        }
6916
6917
      } elseif (($c1 & "\xC0") === "\x80") { // needs conversion
6918
@@ 6922-6926 (lines=5) @@
6919
        $ordC1 = ord($c1);
6920
        if (isset(self::$WIN1252_TO_UTF8[$ordC1])) { // found in Windows-1252 special cases
6921
          $buf .= self::$WIN1252_TO_UTF8[$ordC1];
6922
        } else {
6923
          $cc1 = self::chr_and_parse_int($ordC1 / 64) | "\xC0";
6924
          $cc2 = ($c1 & "\x3F") | "\x80";
6925
          $buf .= $cc1 . $cc2;
6926
        }
6927
6928
      } else { // it doesn't need conversion
6929
        $buf .= $c1;