Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6276-6287 (lines=12) @@
6273
            $buf .= $cc1 . $cc2;
6274
          }
6275
6276
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6277
6278
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6279
            $buf .= $c1 . $c2 . $c3;
6280
            $i += 2;
6281
          } else { // not valid UTF8 - convert it
6282
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6283
            $cc2 = ($c1 & "\x3f") | "\x80";
6284
            $buf .= $cc1 . $cc2;
6285
          }
6286
6287
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6288
6289
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6290
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 6289-6296 (lines=8) @@
6286
6287
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6288
6289
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6290
            $buf .= $c1 . $c2 . $c3 . $c4;
6291
            $i += 3;
6292
          } else { // not valid UTF8 - convert it
6293
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6294
            $cc2 = ($c1 & "\x3f") | "\x80";
6295
            $buf .= $cc1 . $cc2;
6296
          }
6297
6298
        } else { // doesn't look like UTF8, but should be converted
6299
          $cc1 = (chr(ord($c1) / 64) | "\xc0");