message byte size

74 views
Skip to first unread message

rumman

unread,
Feb 28, 2012, 6:52:27 AM2/28/12
to apns-php
Hi,
some time ago I got very strange error while sending a message:
Internal error (116 bytes written instead of 106 bytes) (999)
The cause is here:
strlen($aMessage['BINARY_NOTIFICATION']); // 106
@fwrite($this->_hSocket, $aMessage['BINARY_NOTIFICATION']); // 116

strlen counts correctly number of bytes also when multibyte character
set is used.

However php mbstring extension comes with nice backstabbing feature
called mbstring.func_overload.
http://php.net/manual/en/mbstring.overload.php
When this is active, strlen actually returns number of *characters*

there are two suggestions how to avoid it.First one seems shorter but
it includes string conversion.

http://php.net/manual/en/function.strlen.php#54906 (bartek at
proteus,pl 19-Jul-2005 05:08)
http://www.php.net/manual/en/function.strlen.php#72274 (paolo dot
mosna at gmail dot com 10-Jan-2007 07:58)

I would appreciate if you find time to integrate correct byte counting
also for this php setting, because i can not turn it off.

Thank you very much,
Roman

Dhaya

unread,
Apr 5, 2012, 9:07:24 AM4/5/12
to apns...@googlegroups.com
You saved my day. Thank you!

I don't know if it has other implications but for the time being, I did as hinted by the first php.net post, so I replaced the strlen method with the mb_strlen one to get $nLen.
Reply all
Reply to author
Forward
0 new messages