-3
string recievedData = ExecCommand(port, "AT", 300, "No phone connected");
recievedData = ExecCommand(port, "AT+CMGF=1", 300, "Failed to set message format.");
String command = "AT+CMGS=\"" + PhoneNo + "\"";
recievedData = ExecCommand(port, command, 300, "Failed to accept phoneNo");
command =  "عربي"+ char.ConvertFromUtf32(26) + "\r";
recievedData = ExecCommand(port, command, 3000, "Failed to send message");

code is running very good with English code send ??????? with arabic characters

ckruczek
  • 2,361
  • 2
  • 20
  • 23
  • Related: https://stackoverflow.com/questions/15312059/sending-unicode-messages-such-as-in-persian-and-arabic-in-c-sharp-using-at-com but I would advise using a library like gsmcomm and talk to the hardware in PDU mode rather than text mode. – Alex K. Jul 04 '17 at 11:28
  • Worth nothing that OP is trying out to write C#/Unicode `"عربي"` to the terminal and the AT+CSCS is not even set – quetzalcoatl May 18 '18 at 08:00

1 Answers1

2

The default encoding for SerialPort is Encoding.ASCII. You could set the encoding to UTF32. Or convert the string to bytes and send it that way.

Encoding enc = new UTF8Encoding(true, true);
YourPort.Encoding = enc;

var bytes = Encoding.Unicode.GetBytes("عربي");
LtObelix
  • 61
  • 3