Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6309-6320 (lines=12) @@
6306
            $buf .= $cc1 . $cc2;
6307
          }
6308
6309
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6310
6311
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6312
            $buf .= $c1 . $c2 . $c3;
6313
            $i += 2;
6314
          } else { // not valid UTF8 - convert it
6315
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6316
            $cc2 = ($c1 & "\x3f") | "\x80";
6317
            $buf .= $cc1 . $cc2;
6318
          }
6319
6320
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6321
6322
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6323
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 6322-6329 (lines=8) @@
6319
6320
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6321
6322
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6323
            $buf .= $c1 . $c2 . $c3 . $c4;
6324
            $i += 3;
6325
          } else { // not valid UTF8 - convert it
6326
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6327
            $cc2 = ($c1 & "\x3f") | "\x80";
6328
            $buf .= $cc1 . $cc2;
6329
          }
6330
6331
        } else { // doesn't look like UTF8, but should be converted
6332
          $cc1 = (chr(ord($c1) / 64) | "\xc0");