Search code examples
phpunicode7-bit

Carriage Return Detecting as Unicode


I am using this SMS Counter PHP Class Library for one of my project.

$msg = $_REQUEST['msg'];
$scounter = SMSCounter::count(utf8_urldecode($msg));

When I use Carriage Return or Enter key in the msg text area, it is detecting as Unicode and hence my message counting goes for a toss. As per the class, it counts the message as Unicode of / 67 chars and counts 4 times.

I googled since yesterday for a solution and I could not understand, how could I stop the lib class to consider Carriage Return or Enter key as GSM_7bit instead of Unicode.

Please help!


Solution

  • Add chr(13) to your 7Bit map function, it will detect as GSM 7Bit.

    public static function int_gsm_7bit_map(){
        return array(10,13,32.........
    

    Hope this helps.