i found this code for connect and sms throw usb modem it works fine for english only - when i try to send arabic sms i got " ???? " in mobile so can any one help please ?
all code in class "clsSMS":
public void port_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { if (e.EventType == SerialData.Chars) { receiveNow.Set(); } } catch (Exception) { throw; } } public SerialPort OpenPort(string p_strPortName, int p_uBaudRate, int p_uDataBits, int p_uReadTimeout, int p_uWriteTimeout) { receiveNow = new AutoResetEvent(false); SerialPort port = new SerialPort(); try { port.PortName = p_strPortName; //COM1 port.BaudRate = p_uBaudRate; //9600 port.DataBits = p_uDataBits; //8 port.StopBits = StopBits.One; //1 port.Parity = Parity.None; //None port.ReadTimeout = p_uReadTimeout; //300 port.WriteTimeout = p_uWriteTimeout; //300 port.Encoding = Encoding.GetEncoding("iso-8859-1"); port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived); port.Open(); port.DtrEnable = true; port.RtsEnable = true; } catch (Exception) { throw; } return port; } public void ClosePort(SerialPort port) { try { port.Close(); port.DataReceived -= new SerialDataReceivedEventHandler(port_DataReceived); port = null; } catch (Exception) { throw; } } public bool sendMsg(SerialPort port, string PhoneNo, string Message) { bool isSend = false; try { 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 = Message + "\r"; recievedData = ExecCommand(port,command, 3000, "Failed to send message"); //3 seconds if (recievedData.EndsWith("\r\nOK\r\n")) { isSend = true; } else if (recievedData.Contains("ERROR")) { isSend = false; } return isSend; } catch (Exception) { throw; } } i use the code as:
SerialPort port = new SerialPort(); clsSMS objclsSMS = new clsSMS(); private void btnSendSMS_Click(object sender, EventArgs e) { //.............................................. Send SMS .................................................... try { if (objclsSMS.sendMsg(port, txtSIM.Text, txtMessage.Text)) { //MessageBox.Show("Message has sent successfully"); statusBar1.Text = "Message has sent successfully"; } else { //MessageBox.Show("Failed to send message"); statusBar1.Text = "Failed to send message"; } } catch (Exception) { throw; } }so please can any body tell me how can i fix code to send arabic sms - i try to change
port.Encoding = Encoding.GetEncoding("iso-8859-1");to be "UTF-8" but not working ???