Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这段代码
print mb_substr('éxxx', 0, 1);
打印一个空白空间:(
它应该打印第一个字符,é. 然而,这似乎有效:
é
print mb_substr('éxxx', 0, 2);
但这是不对的,因为 (0, 2) 表示 2 个字符...
尝试将编码参数传递给 mb_substr,如下所示:
print mb_substr('éxxx', 0, 1, 'utf-8');
永远不会自动检测到编码。
在实践中,我发现在某些系统中,多字节函数默认使用 ISO-8859-1 进行内部编码。这实际上破坏了他们处理多字节文本的能力。
设置一个好的默认值可能会解决这个问题和其他一些问题:
mb_internal_encoding('UTF-8');