is there any easy way to truncate chinese characters i found that regexp but it doesn't work as expected
<?php
$data1='疯狂的管道Test';
$data2='睡眠帮手-背景乐Test';
echo str_replace(preg_replace("/[^\x{4e00}-\x{9fa5}]+/u", '', $data1),'',$data1)
."<br>\n".
str_replace(preg_replace("/[^\x{4e00}-\x{9fa5}]+/u", '', $data2),'',$data2);
exit;
it works for data1 but not data2
How does Chinese writing work? Unlike English, Chinese does not use an alphabet to record the written word; instead, it uses a system of ideogrammatic characters – 汉字 hànzì in Chinese. With this system, every character represents one syllable and each syllable has its own meaning.
Step one: At the bottom right, select the time. Step two: Select Settings Settings and then Advanced. Step three: In the "Languages and input" section, select Language. Step four: Next to the language you want to remove, select More More and then Remove.
You can use a Unicode character property (Han should work for you):
preg_replace("/\p{Han}+/u", '', $data)
Working example: http://ideone.com/uEiIV5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With