This is my PHP code:
I suppose, your code is in windows-1251 encoding since it is Russian :) convert your string to utf-8:
windows-1251
$str = iconv('windows-1251', 'utf-8', $str);