请帮帮我 $ string =“细分”; echo strlen($ string);
Output: 23;
我想输出 输出:11;
答案 0 :(得分:1)
我相信你的字符串编码为UTF-16,而strlen正在将其计算为UTF-8
您的php文件的字符编码是UTF-16,或者字符串来自以UTF-16编码的字符串
答案 1 :(得分:1)
使用mb_strlen
功能:
echo mb_strlen($string);
答案 2 :(得分:0)
您可以先在strlen
之前转换变量编码$string = "Subdivision";
// $string = mb_convert_encoding($string, "UTF-16"); //just a test and its print 22 as you and user3647971 said
$string = mb_convert_encoding($string, "UTF-8");
echo strlen($string);