求助: MTK 6252 发送中文短信问题
时间:10-02
整理:3721RD
点击:
发送英文数字是能够发送的,发送中文时接收到的是乱码,求教如何修改?
贴出代码如下:
/*调试开始==========================================================*/
S8 number[12]="13774937494";
U16 numberUCS2[12] ;
S8 Content[10]= "Hello,MTK"; //"你好吗MTK";
U16 ContentUCS2[10];
memset(numberUCS2,0,strlen(number)*2); //初始化内存
mmi_asc_to_ucs2((PS8)numberUCS2,(PS8)number); //ascii转unicode
memset(ContentUCS2,0,sizeof(ContentUCS2)); //初始化内存
mmi_asc_to_ucs2((PS8)ContentUCS2,(PS8)Content); //ascii转unicode
mmi_rej_by_sms_sendreq((S8*)numberUCS2,(U16*)ContentUCS2);
return;
/*调试结束==========================================================*/
//发送短信完成后的回调函数
void send_message_callback(srv_sms_callback_struct* callback_data)
{ return;
}
//短信发送函数
void mmi_rej_by_sms_sendreq(S8* number, U16* content)
{
SMS_HANDLE send_handle;
send_handle = srv_sms_get_send_handle();
if (send_handle == NULL)
{ return;
}
if ((U16)srv_sms_is_bg_send_action_busy() == MMI_TRUE)
{ return;
}
srv_sms_set_address(send_handle, number);
srv_sms_set_content_dcs(send_handle, SRV_SMS_DCS_UCS2);
srv_sms_set_content(send_handle, (S8*)content, (U16)((mmi_wcslen(content)+1)*2));
srv_sms_set_sim_id(send_handle, SRV_SMS_SIM_1);
srv_sms_send_msg(send_handle, send_message_callback, NULL);
}
贴出代码如下:
/*调试开始==========================================================*/
S8 number[12]="13774937494";
U16 numberUCS2[12] ;
S8 Content[10]= "Hello,MTK"; //"你好吗MTK";
U16 ContentUCS2[10];
memset(numberUCS2,0,strlen(number)*2); //初始化内存
mmi_asc_to_ucs2((PS8)numberUCS2,(PS8)number); //ascii转unicode
memset(ContentUCS2,0,sizeof(ContentUCS2)); //初始化内存
mmi_asc_to_ucs2((PS8)ContentUCS2,(PS8)Content); //ascii转unicode
mmi_rej_by_sms_sendreq((S8*)numberUCS2,(U16*)ContentUCS2);
return;
/*调试结束==========================================================*/
//发送短信完成后的回调函数
void send_message_callback(srv_sms_callback_struct* callback_data)
{ return;
}
//短信发送函数
void mmi_rej_by_sms_sendreq(S8* number, U16* content)
{
SMS_HANDLE send_handle;
send_handle = srv_sms_get_send_handle();
if (send_handle == NULL)
{ return;
}
if ((U16)srv_sms_is_bg_send_action_busy() == MMI_TRUE)
{ return;
}
srv_sms_set_address(send_handle, number);
srv_sms_set_content_dcs(send_handle, SRV_SMS_DCS_UCS2);
srv_sms_set_content(send_handle, (S8*)content, (U16)((mmi_wcslen(content)+1)*2));
srv_sms_set_sim_id(send_handle, SRV_SMS_SIM_1);
srv_sms_send_msg(send_handle, send_message_callback, NULL);
}
mmi_asc_to_ucs2((PS8)ContentUCS2,(PS8)Content); //ascii转unicode
这个有问题,mmi_asc_to_ucs2 只能转换 ascii,不能转换 gbk.用 mmi_chset_convert,可能还要打开 gbk 开关