What is the difference between the iconv_strlen, mb_strlen and strlen functions?
And what is each used for in the real world?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The difference of
strlen()tomb_strlen()is, that the second respects multibyte characters. This means, that this is the real character count. The first one assumes, that the string is always in ascii, what also means, that it always returns the size in bytes (very useful when handling binary “strings”).As far as I can see
iconv_strlen()is quite similar tomb_strlen(), but fails on bad character sequences, in contrast tomb_strlen(), that just ignores them. And it uses theiconv-library (obviously ;)).