简体   繁体   English

PHP iconv_strlen function显示问题

[英]PHP iconv_strlen function display problem

In the code below I'm trying to get the bytes for the characterwhich should be 3 for the first function but I keep getting the value of 1 for each iconv_strlen function below.在下面的代码中,我试图获取字符的字节,第一个 function 的字节应该是 3,但我不断为下面的每个 iconv_strlen function 获取 1 的值。 How can I figure out why this is?我怎样才能弄清楚这是为什么?

Here is the code:这是代码:

echo iconv_strlen("こ") . '<br />';
echo iconv_strlen("こ", "UTF-8") . '<br />';

Correct value in first case is 1, not 3.第一种情况下的正确值是 1,而不是 3。
If you want to get count of bytes, you can use strlen() function, or change iconv.internal_encoding directive in php.ini or by ini_set() (to ISO-8859-1 ) - but it will affect all iconv -functions, so I recommend to use strlen() .如果要获取字节数,可以使用strlen() function,或更改iconv.internal_encoding中的 iconv.internal_encoding 指令或通过ini_set() (到ISO-8859-1 ) - 但它会影响所有iconv -functions,所以我建议使用strlen()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM