SQLBOX UTF-8 FIX

Сергей Бочаров <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi!
there was problems with sending cyrillic messages via sqlbox with oracle. But no problem with smsbox. Now I find a solution:

in file sqlbox.c

change this:

 if(pmsg->sms.coding == 2)
octstr_hex_to_binary(pmsg->sms.msgdata); 


to this:

    if(pmsg->sms.coding == 2) 
    {
      /*Default charset is UTF-8 */
      if (octstr_len(pmsg->sms.charset)<1) {
          pmsg->sms.charset=octstr_create("UTF-8");
      }
      /*For UCS-2, convert to UTF-16BE */
      if (charset_convert(pmsg->sms.msgdata, octstr_get_cstr(pmsg->sms.charset), "UTF-16BE") < 0) {                                                            
        return  -1;
     }
    }

And for correct inserting message text into sent_sms table in file sqlbox_oracle.c ( or sqlbox_mysql.c or other - depends on your database)

change this:

    if(msg->sms.coding == 2)
             octstr_binary_to_hex(msg->sms.msgdata,1);


to this:

 if(msg->sms.coding == 2)
   {
      /*Default charset is UTF-8 */
      if (octstr_len(msg->sms.charset)<1) {
          msg->sms.charset=octstr_create("UTF-8");
      }
      /*For UCS-2, convert from UTF-16BE  */
      charset_convert(msg->sms.msgdata, "UTF-16BE",octstr_get_cstr(msg->sms.charset));


    }




It is simple workaround but I hope that developers will transfer charsets support from smsbox to sqlbox sometime ;-)

Bye!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.