Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6155-6166 (lines=12) @@
6152
            $buf .= $cc1 . $cc2;
6153
          }
6154
6155
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6156
6157
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6158
            $buf .= $c1 . $c2 . $c3;
6159
            $i += 2;
6160
          } else { // not valid UTF8 - convert it
6161
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6162
            $cc2 = ($c1 & "\x3f") | "\x80";
6163
            $buf .= $cc1 . $cc2;
6164
          }
6165
6166
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6167
6168
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6169
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 6168-6175 (lines=8) @@
6165
6166
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6167
6168
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6169
            $buf .= $c1 . $c2 . $c3 . $c4;
6170
            $i += 3;
6171
          } else { // not valid UTF8 - convert it
6172
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6173
            $cc2 = ($c1 & "\x3f") | "\x80";
6174
            $buf .= $cc1 . $cc2;
6175
          }
6176
6177
        } else { // doesn't look like UTF8, but should be converted
6178
          $cc1 = (chr(ord($c1) / 64) | "\xc0");