ZF-5637: Wrong handling of UTF8 strings length.

Issue Type: Bug Created: 2009-01-27T00:27:45.000+0000 Last Updated: 2009-02-06T09:50:59.000+0000 Status: Resolved Fix version(s): - 1.7.5 (16/Feb/09)

Reporter: Arik Fraimovich (arikfr) Assignee: Jon Whitcraft (sidhighwind) Tags: - Zend_Service_Twitter

Related issues: Attachments: - zf5637.patch


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.


Posted by Thomas Weidner (thomas) on 2009-01-28T07:16:49.000+0000

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

Posted by Thomas Weidner (thomas) on 2009-01-28T09:59:03.000+0000

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.

Posted by Jon Whitcraft (sidhighwind) on 2009-01-28T10:12:55.000+0000

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

Posted by Arik Fraimovich (arikfr) on 2009-01-28T22:48:28.000+0000

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.

Posted by Jon Whitcraft (sidhighwind) on 2009-02-05T05:56:37.000+0000

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

Posted by Jon Whitcraft (sidhighwind) on 2009-02-06T08:56:08.000+0000

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

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.