Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 1919-1930 (lines=12) @@
1916
            $buf .= $cc1 . $cc2;
1917
          }
1918
1919
        } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
1920
1921
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
1922
            $buf .= $c1 . $c2 . $c3;
1923
            $i += 2;
1924
          } else { // not valid UTF8 - convert it
1925
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
1926
            $cc2 = ($c1 & "\x3f") | "\x80";
1927
            $buf .= $cc1 . $cc2;
1928
          }
1929
1930
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
1931
1932
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
1933
            $buf .= $c1 . $c2 . $c3 . $c4;
@@ 1932-1939 (lines=8) @@
1929
1930
        } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
1931
1932
          if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
1933
            $buf .= $c1 . $c2 . $c3 . $c4;
1934
            $i += 3;
1935
          } else { // not valid UTF8 - convert it
1936
            $cc1 = (chr(ord($c1) / 64) | "\xc0");
1937
            $cc2 = ($c1 & "\x3f") | "\x80";
1938
            $buf .= $cc1 . $cc2;
1939
          }
1940
1941
        } else { // doesn't look like UTF8, but should be converted
1942
          $cc1 = (chr(ord($c1) / 64) | "\xc0");