immobiliare / ApnsPHP

ApnsPHP: Apple Push Notification & Feedback Provider
BSD 3-Clause "New" or "Revised" License
1.43k stars 449 forks source link

Changed strlen for binary data to take into account mbstring.func_overload #71

Open pmxmatt opened 10 years ago

pmxmatt commented 10 years ago

The function strlen behaves differently when mbstring.func_overload is enabled for the strlen function.

This was causing the message sending to fail I've updated the code based on the comment from a user on the official documentation http://php.net/manual/en/function.strlen.php#54906 .

duccio commented 10 years ago

Hi, thanks but… latin1?

pmxmatt commented 10 years ago

Using latin1 forces it into single-byte mode.

I've tested this with both mbstring.func_overload on and off in environment and it is now counting correctly.

lucabrunox commented 9 years ago

What's the point of checking mbstring.func_overload if mb_strlen($aMessage['BINARY_NOTIFICATION'],'latin1'); does always the right job? It could be used in place of strlen always I guess.