In the code below I'm trying to get the bytes for the character こ
which should be 3 for the first function but I keep getting the value of 1 for each 开发者_运维技巧iconv_strlen function below. 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.
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()
.
精彩评论