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

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

问题描述

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

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(波斯语或阿拉伯语消息)方面遇到了类似的问题.请检查我的问题和答案 此主题.在此线程中,您可以了解如何正确发送 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-command 发送阿拉伯语短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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