ZF-5637: Wrong handling of UTF8 strings length.


Before sending a tweet or direct message, the library checks for the length of the message for length. It uses strlen to do that, which returns wrong length for UTF8 strings. The correct way to do this is using the mb_strlen function.

I couldn't find how I can comment on the issue too, so here's my reply to Thomas: If you mean to use iconv to convert to something not multibyte, do strlen and then run iconv again - that might work. Otherwise it won't, because Twitter expect the input in UTF8.


No, we have to use iconv as iconv is available within default PHP installations. But the mbstr* extension is not available per default.

I think you completly misunderstood...

The iconv extension has a own iconv_strlen function which does the same as the mb_strlen function. Why should we convert something, and then reconvert it. This is completly useless.

Please take a look at the PHP manual to see what PHP supports.

I will get a patch up here for approval by Zend before i post it to the trunk.

I was thinking you meant the iconv function... wasn't aware that it's part of an extension that also includes strlen. In that case, you're completely right of course.

Attached my proposed patch. I will have Ralph or someone from Zend take a look at it.

This was checked into the trunk with r13992 and into the release branch with r13993