Code Duplication    Length = 5-6 lines in 5 locations

src/voku/helper/UTF8.php 5 locations

@@ 7094-7099 (lines=6) @@
7091
          if ($c2 >= "\x80" && $c2 <= "\xBF") { // yeah, almost sure it's UTF8 already
7092
            $buf .= $c1 . $c2;
7093
            $i++;
7094
          } else { // not valid UTF8 - convert it
7095
            $cc1tmp = ord($c1) / 64;
7096
            $cc1 = self::chr_and_parse_int($cc1tmp) | "\xC0";
7097
            $cc2 = ($c1 & "\x3F") | "\x80";
7098
            $buf .= $cc1 . $cc2;
7099
          }
7100
7101
        } elseif ($c1 >= "\xE0" && $c1 <= "\xEF") { // looks like 3 bytes UTF8
7102
@@ 7109-7114 (lines=6) @@
7106
          if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF") { // yeah, almost sure it's UTF8 already
7107
            $buf .= $c1 . $c2 . $c3;
7108
            $i += 2;
7109
          } else { // not valid UTF8 - convert it
7110
            $cc1tmp = ord($c1) / 64;
7111
            $cc1 = self::chr_and_parse_int($cc1tmp) | "\xC0";
7112
            $cc2 = ($c1 & "\x3F") | "\x80";
7113
            $buf .= $cc1 . $cc2;
7114
          }
7115
7116
        } elseif ($c1 >= "\xF0" && $c1 <= "\xF7") { // looks like 4 bytes UTF8
7117
@@ 7125-7130 (lines=6) @@
7122
          if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF" && $c4 >= "\x80" && $c4 <= "\xBF") { // yeah, almost sure it's UTF8 already
7123
            $buf .= $c1 . $c2 . $c3 . $c4;
7124
            $i += 3;
7125
          } else { // not valid UTF8 - convert it
7126
            $cc1tmp = ord($c1) / 64;
7127
            $cc1 = self::chr_and_parse_int($cc1tmp) | "\xC0";
7128
            $cc2 = ($c1 & "\x3F") | "\x80";
7129
            $buf .= $cc1 . $cc2;
7130
          }
7131
7132
        } else { // doesn't look like UTF8, but should be converted
7133
          $cc1tmp = ord($c1) / 64;
@@ 7132-7137 (lines=6) @@
7129
            $buf .= $cc1 . $cc2;
7130
          }
7131
7132
        } else { // doesn't look like UTF8, but should be converted
7133
          $cc1tmp = ord($c1) / 64;
7134
          $cc1 = self::chr_and_parse_int($cc1tmp) | "\xC0";
7135
          $cc2 = ($c1 & "\x3F") | "\x80";
7136
          $buf .= $cc1 . $cc2;
7137
        }
7138
7139
      } elseif (($c1 & "\xC0") === "\x80") { // needs conversion
7140
@@ 7144-7148 (lines=5) @@
7141
        $ordC1 = ord($c1);
7142
        if (isset(self::$WIN1252_TO_UTF8[$ordC1])) { // found in Windows-1252 special cases
7143
          $buf .= self::$WIN1252_TO_UTF8[$ordC1];
7144
        } else {
7145
          $cc1 = self::chr_and_parse_int($ordC1 / 64) | "\xC0";
7146
          $cc2 = ($c1 & "\x3F") | "\x80";
7147
          $buf .= $cc1 . $cc2;
7148
        }
7149
7150
      } else { // it doesn't need conversion
7151
        $buf .= $c1;