Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6390-6401 (lines=12) @@
6387
            $buf .= $cc1 . $cc2;
6388
          }
6389
6390
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6391
6392
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6393
            $buf .= $c1 . $c2 . $c3;
6394
            $i += 2;
6395
          } else { // not valid UTF8 - convert it
6396
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6397
            $cc2 = ($c1 & "\x3f") | "\x80";
6398
            $buf .= $cc1 . $cc2;
6399
          }
6400
6401
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6402
6403
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6404
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 6403-6410 (lines=8) @@
6400
6401
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6402
6403
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6404
            $buf .= $c1 . $c2 . $c3 . $c4;
6405
            $i += 3;
6406
          } else { // not valid UTF8 - convert it
6407
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6408
            $cc2 = ($c1 & "\x3f") | "\x80";
6409
            $buf .= $cc1 . $cc2;
6410
          }
6411
6412
        } else { // doesn't look like UTF8, but should be converted
6413
          $cc1 = (chr(ord($c1) / 64) | "\xc0");