PDU短信发送编码程序(C#)

时间:2013-07-09 09:39:57
【文件属性】:
文件名称:PDU短信发送编码程序(C#)
文件大小:3KB
文件格式:TXT
更新时间:2013-07-09 09:39:57
PDU 短信 编码 C# 程序中的sp是SerialPort类型的对象,在System.IO.Ports命名空间下 //手机号码转换为pdu模式 private string telc(string MobileNum) { int tl; string ltem, rtem, ttem; int ti; ttem = ""; tl = MobileNum.Trim().Length; if (tl != 11 && tl != 13) { MessageBox.Show("wrong number:" + MobileNum); return ""; } if (tl == 11) // 11位转换为13位 { tl += 2; MobileNum = "86" + MobileNum; } for (ti = 0; ti < tl; ti += 2) { ltem = MobileNum.Substring(ti, 1); if (ti == tl - 1) { rtem = "F"; } else { rtem = MobileNum.Substring(ti + 1, 1); } ttem += rtem + ltem; //每两位颠倒 } return ttem; } //Unicode解码函数 private string ascg(string smsg) { string res=""; string ls; string rs; byte[] resByte = System.Text.UnicodeEncoding.Unicode.GetBytes(smsg); for (int i = 0; i < resByte.Length ; i+=2) { ls = resByte[i].ToString("X2"); rs = resByte[i + 1].ToString("X2"); res = res + rs + ls; //注意这里高低位颠倒 } return res.Trim(); }

网友评论

  • 比较简单,但可以实现基本的功能~
  • 还可以,比较简单
  • 太简单,对于基本功能来说仍然不够
  • 看不懂啊,能否从发点啊!
  • 基本可以实现,太过简单
  • 太简单,对于基本功能来说仍然不够
  • 基本可以实现
  • 基本可以实现
  • 只有一段代码,太过简单,没有实例。不过是可以实现的。