Code Duplication    Length = 8-12 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

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