Working with UTF-8

File in UTF-8 without boma.
HTML signed that UTF-8 too.
Plugs believes.


Answer 1, Authority 100%

<? 
$s='asd';
$test=mb_substr($s, rand(0,19), 1, 'utf-8').mb_substr($s, rand(0,19), 1, 'utf-8');
echo $test;
?>

And what did you want by choosing bytes from the string in UTF8?)


Answer 2, Authority 50%

And then see

In the UTF-8 encoding 1, the symbol takes 2 bytes and what you are displayed correctly.

$s[rand(0,19)]

This will only display a part of the symbol. 🙂
Rewrite the code and read the difference between UTF-8 from Windows-1251