简体   繁体   中英

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. 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() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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