PHP MMSText in Unicode

PHP MMSText in Unicode SearchSearch
Author Message
Joel Parker
New member
Username: Joelparker

Post Number: 8
Registered: 06-2009
Posted on Wednesday, April 17, 2013 - 02:58 pm:   

How can I set the MMSText variable in a PHP script to unicode.

For example (ASCII) :
$mmsMessage = MmsAddField ($mmsMessage, "MMSText", "Hello MMS");

How would I do this with Unicode : (06F106F206F3O6F4)

If I do this :

$mmsMessage = MmsAddField ($mmsMessage, "MMSText", "06F106F206F3O6F4");

It will obviously send the text 06F106F206F3O6F4 instead of the unicode equivalent
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4411
Registered: 08-2008
Posted on Wednesday, April 17, 2013 - 03:52 pm:   

Hi Joel,

You have to use UTF-8 encoding for the text.

--
Des
NowSMS Support
Joel Parker
New member
Username: Joelparker

Post Number: 9
Registered: 06-2009
Posted on Wednesday, April 17, 2013 - 05:49 pm:   

Can you give me an example of the syntax to do that in a PHP script?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4413
Registered: 08-2008
Posted on Wednesday, April 17, 2013 - 06:14 pm:   

Hi Joel,

There is no special syntax, you just enter the text.

For example:
$mmsMessage = MmsAddField ($mmsMessage, "MMSText", "۱۲۳۴");

The PHP file just needs to be saved in UTF-8 format ... which most editors allow, and which PHP will handle natively.

If your editor doesn't support UTF-8, then that is more of a challenge. You'd have to convert to UTF-8 (PHP has character set conversion functions) and URL encode.

URL encoding of your example characters would look like this:

$mmsMessage = MmsAddField ($mmsMessage, "MMSText", "%DB%B1%DB%B2%DB%B3%DB%B4");

(UTF-8 encoding of 06F1 is the byte sequence DB B1, which URL encodes as %DB%B1.)

--
Des
NowSMS Support