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 changeiconv.internal_encodingdirective in php.ini or byini_set()(toISO-8859-1) – but it will affect alliconv-functions, so I recommend to usestrlen().