strlen()
is not handling multibyte characters correctly, as it assumes 1 char equals 1 byte, which is simply invalid for unicode. This behavior is clearly documented:
strlen() returns the number of bytes rather than the number of characters in a string.
The solution is to use mb_strlen()
function instead (mb
stands for multi byte
) (see mb_strlen() docs).