SMS Server Tools 3
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. The forum is currently read-only, but will open soon. Sat Oct 12, 2024 09:53
SMSTools3 Community » Help and support Bottom

[solved] Cannot receive Chinese SMS

  This topic is locked

Page:  1

Author Post
Member
Registered:
Dec 2009
Location: Singapore
I need some help here. Am using SMS Server Tools with PlaySMS Web Interface.

To send Chinese SMS, i need to tick a unicode checkbox and it is supposed to send it.

if ($unicode){
$the_msg .= "Alphabet: UCS2\n";
// $sms_msg = mb_convert_encoding($sms_msg, "UCS-2", "auto");
}
$the_msg .= "\n$sms_msg";

But I only receive a SMS like the following:
主任

I tried to add the checkhandler advised by administrator, but to no avail.

Any other suggestions?

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
The PlaySMS page does not define a character set and therefore a browser will use a default character set. I think that in your browser it's something else than UTF-8. In this case change it to UTF-8 and try again without checkhandler and with character set conversion in PHP code:
$sms_msg = mb_convert_encoding($sms_msg, "UCS-2BE", "auto");

The value "UCS-2BE" is correct, not "UCS-2".

I tested this with a message: 世界您好。(it's from translate.google.com)
My phone was unable to show the message correctly, but when I checked the sent PDU with this tool, the result was:

...
Alphabet:UCS2(16)bit

世界您好。 - playSMS
Length:15

So I think that the result is correct and should work with Chinese phones.

Member
Registered:
Dec 2009
Location: Singapore
Topic owner
Thank you!

I change the default character set to UTF-8 in my browser and do the php code change to

$sms_msg = mb_convert_encoding($sms_msg, "UCS-2BE", "auto");

Now, it works!

And i added in the default character set into the PlaySMS header.php:

<META http-equiv=Content-Type content="text/html; charset=UTF-8">

Can i ask how do i remove the need for user to tick on unicode checkbox in order to send Chinese characters? Can the php code or checkhandler auto-detect that there is unicode in the sms content without explicitly declaring that it is a unicode?

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
There is no code available for detecting character set in PHP or checkhandler. It can be done, but as far as I know, no one has done it.

In your case, probably all (or almost all) messages are sent using Chinese alphabet, right? In this case you could use Unicode for all messages. In the PlaySMS code, hide the checkbox and make it checked by default. After this, if some message could be sent using SMS alphabet, it's still sent using Unicode. More message parts are used (70 characters vs. 160 characters / part), but there are no other problems.

Member
Registered:
Dec 2009
Location: Singapore
Topic owner
Thanks Keke.

My main language is still English. Just want to provide flexibility to send sms in Chinese. But it may pose a problem to let user tick the unicode checkbox (e.g. they may forget to tick it). I am wondering how some online sms website manage to overcome this problem by not enabling the unicode checkbox and yet still retain the 160 sms-length when no unicode content is detected.

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
I do not know any public online sms website which will do the checking automatically and correctly. In most cases, also the counting of characters fails, because extended characters are not noticed and they are sent using two characters.

Perhaps you could try this simple workaround: Add this code to the plugin/gateway/smstools/fn.php file:

   if ($msg_type=="flash")
   {
       $the_msg .= "Flash: yes\n";
   }

   if (!$unicode)
     if (mb_detect_encoding($sms_msg) == "UTF-8")
       $unicode = 1;

   if ($unicode)
   {
       $the_msg .= "Alphabet: UCS\n";

This solution is not perfect, but may work if only English letters are used in the SMS. Any other letters will cause Unicode to be used.

For example:

mb_detect-encoding( "This is a test message." ) returns ASCII.

mb_detect-encoding( "世界您好。" ) returns UTF-8.

but mb_detect_encoding( "Hello from Jyväskylä." ) return UTF-8 too, which makes this solution not good for users in Europe.

Member
Registered:
Dec 2009
Location: Singapore
Topic owner
Wow! That workaround will suffice for now.

Thank you, KeKe!!

  This topic is locked

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.