(铂)字符串函数和php中的UTF8 [英] (鉑) string functions and UTF8 in php
本文介绍了(铂)字符串函数和php中的UTF8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么以下语句的输出为3而不是1?
Why is the output of the following statement 3 and not 1?
echo mb_strlen("鉑");
事情就是
echo "鉑";
将正确输出此编码为UTF-8的符号.
will properly output this sign which is encoded as UTF-8.
推荐答案
请确保设置了正确的内部编码:
Make sure you set the proper internal encoding:
<?php
echo mb_internal_encoding() . '<br />';
echo mb_strlen('鉑', 'utf-8') . '<br />';
echo mb_strlen('鉑') . '<br />';
mb_internal_encoding('utf-8');
echo mb_internal_encoding() . '<br />';
echo mb_strlen('鉑') . '<br />';
// ISO-8859-1
// 1
// 3
// UTF-8
// 1
这篇关于(铂)字符串函数和php中的UTF8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文