unicodeclickatell

Dynamic unicode message content


My message body is dynamic and sometimes it contain apostrophe (`). For eg: Swifty’s Car

Message is not displaying correctly on the receipent phone "Swiftya€?s Car"

How can I fix this? I can not use the "Unicode Converter" tool since my message body is dynamic.

https://api.clickatell.com/http/sendmsg?user=XXX&password=XXX&api_id=XXX&to=XXX&text=Swifty’s Car

Ouput: Swiftya€?s Car

Then I converted the apostrophe to unicode using "Unicode Converter" tool

https://api.clickatell.com/http/sendmsg?user=XXX&password=XXX&api_id=XXX&to=XXX&text=Swifty2019s Car&unicode=1

Ouput: ERR: 116, Invalid Unicode data


Solution

  • I solved this by converting it to unicode using following script

    $smsBody = mb_convert_encoding($smsBody, "UTF-16");
    $smsBody = bin2hex($smsBody);