Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 6241-6252 (lines=12) @@
6238
            $buf .= $cc1 . $cc2;
6239
          }
6240
6241
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6242
6243
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6244
            $buf .= $c1 . $c2 . $c3;
6245
            $i += 2;
6246
          } else { // not valid UTF8 - convert it
6247
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6248
            $cc2 = ($c1 & "\x3f") | "\x80";
6249
            $buf .= $cc1 . $cc2;
6250
          }
6251
6252
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6253
6254
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6255
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 6254-6261 (lines=8) @@
6251
6252
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6253
6254
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6255
            $buf .= $c1 . $c2 . $c3 . $c4;
6256
            $i += 3;
6257
          } else { // not valid UTF8 - convert it
6258
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
6259
            $cc2 = ($c1 & "\x3f") | "\x80";
6260
            $buf .= $cc1 . $cc2;
6261
          }
6262
6263
        } else { // doesn't look like UTF8, but should be converted
6264
          $cc1 = (chr(ord($c1) / 64) | "\xc0");