Reputation: 4608
I have a strange result with:
strlen("òàùè")
How can I count correctly the string with no-ASCII characters?
I also looked at mb_strlen(), but it does not solve the problem.
Upvotes: 1
Views: 1618
Reputation: 317177
mb_strlen
will
Return the number of characters in string $str having character encoding $encoding. A multi-byte character is counted as 1.
Your internal encoding is likely not set to UTF-8, so do
echo mb_strlen('òàùè', 'UTF-8');
Or set UTF-8 globally:
mb_internal_encoding('UTF-8');
And then do
echo mb_strlen("òàùè");
will give 4 (demo).
Upvotes: 11