Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 2011-2022 (lines=12) @@
2008
            $buf .= $cc1 . $cc2;
2009
          }
2010
2011
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
2012
2013
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
2014
            $buf .= $c1 . $c2 . $c3;
2015
            $i += 2;
2016
          } else { // not valid UTF8 - convert it
2017
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
2018
            $cc2 = ($c1 & "\x3f") | "\x80";
2019
            $buf .= $cc1 . $cc2;
2020
          }
2021
2022
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
2023
2024
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
2025
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 2024-2031 (lines=8) @@
2021
2022
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
2023
2024
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
2025
            $buf .= $c1 . $c2 . $c3 . $c4;
2026
            $i += 3;
2027
          } else { // not valid UTF8 - convert it
2028
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
2029
            $cc2 = ($c1 & "\x3f") | "\x80";
2030
            $buf .= $cc1 . $cc2;
2031
          }
2032
2033
        } else { // doesn't look like UTF8, but should be converted
2034
          $cc1 = (chr(ord($c1) / 64) | "\xc0");