Making directories in cyrillic removes first word

Hello.

I’m having a weird issue. When I make a directory with php mkdir function and use cyrillic charachters the first word is removed. I use htmlentities together with the name, so there are no encoding problems like this:

$dir = ‘./somedir/’.htmlentities($_POST[‘dir_name’]);
mkdir($dir);

If the directory name is “яяяя юююю” it will be named only “юююю”, for example.
This problem only happens here for me.

Have a look at this post