如何在C#中使用at命令发送阿拉伯短信 [英] how to send arabic sms with at-command in c#

查看:212
本文介绍了如何在C#中使用at命令发送阿拉伯短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中使用at命令发送阿拉伯语SMS?当我发送阿拉伯语消息时,它显示不正确的字符.

How can I send Arabic SMS with the at command in C#? When I send Arabic messages it shows incorrect characters.

我尝试使用此代码:

serialPort1.BaseStream.Flush();

            string cb = char.ConvertFromUtf32(26);

            System.Threading.Thread.Sleep(2000);

            this.serialPort1.Write("AT+CMGF=1\r");
            this.serialPort1.Write("AT+CSCA=servicecenter\r\n");//Ufone Service Center

            this.serialPort1.Write("AT+CSCS=\"" + "HEX" + "\"\r\n");
            this.serialPort1.Write("AT+CSMP=\"" + 1 + "," + 167 + "," + 0 + ","  +8+ "\"\r\n");
            this.serialPort1.Write("AT+CMGS=\"" + textBox1.Text + "\"\r\n");// message sending
            this.serialPort1.Write(textBox2.Text + cb);//message text

然后我在文本框中写了06450631062D06280627.

and I wrote 06450631062D06280627 in the text box.

推荐答案

我在Unicode(波斯语或阿拉伯语消息)上也遇到了类似的问题.请在

I had similar problem with Unicodes (Persian or Arabic messages). Please check my question and answer in this thread. In this thread you can find out how to send Unicode messages correctly and your problem will be resolved.

请先阅读这篇文章,然后将Unicode消息转换为十六进制格式,然后设置AT+CSCS="UCS2".您的代码的核心应如下所示:

First please read this article then convert your Unicode message to Hex format and set AT+CSCS="UCS2". The core of your code should look like this:

GSMPort.Write("AT\n");
Thread.Sleep(1000);
GSMPort.Write("AT+CSCS=\"UCS2\"\n");
Thread.Sleep(1000);
GSMPort.Write("AT+CMGF=1\n");
Thread.Sleep(1000);
GSMPort.Write("AT+CMGS=\"" + destinationNumber + "\"\n");
Thread.Sleep(1000);
GSMPort.Write("06450631062D0628062706450631062D0628062706450631062D06280627" + "\x1A");

"06450631062D06280627"是مرحبا"的十六进制格式!

"06450631062D06280627" is the Hex format of "مرحبا"!

这篇关于如何在C#中使用at命令发送阿拉伯短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆