Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 5383-5394 (lines=12) @@
5380
            $buf .= $cc1 . $cc2;
5381
          }
5382
5383
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
5384
5385
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
5386
            $buf .= $c1 . $c2 . $c3;
5387
            $i += 2;
5388
          } else { // not valid UTF8 - convert it
5389
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
5390
            $cc2 = ($c1 & "\x3f") | "\x80";
5391
            $buf .= $cc1 . $cc2;
5392
          }
5393
5394
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
5395
5396
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
5397
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 5396-5403 (lines=8) @@
5393
5394
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
5395
5396
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
5397
            $buf .= $c1 . $c2 . $c3 . $c4;
5398
            $i += 3;
5399
          } else { // not valid UTF8 - convert it
5400
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
5401
            $cc2 = ($c1 & "\x3f") | "\x80";
5402
            $buf .= $cc1 . $cc2;
5403
          }
5404
5405
        } else { // doesn't look like UTF8, but should be converted
5406
          $cc1 = (chr(ord($c1) / 64) | "\xc0");