I want to trim full byte spaces from before and after strings. It can contain both Japanese and/or English letters. However, it is not working perfectly for strings starting with hiragana and katakana.
//test1
$text = " romaji ";
var_dump(trim($text," ")); // returns "romaji"
//test2
$text = " ひらがな ";
var_dump(trim($text," ")); // returns "��らがな"
//test3
$text = " カタカナ ";
var_dump(trim($text," ")); // returns "��タカナ"
//test4
$text = " 漢字 ";
var_dump(trim($text," ")); // returns "漢字"
Why is the code not working for test 2 and 3? How can we solve it?