|
(原文件名:aa.JPG)
点击此处下载 ourdev_705514VSOX1I.rar(文件大小:44K) (原文件名:GBtoUCS2.rar)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GBtoUCS2
{
public partial class Form1 : Form
{
string userDataLenghth;
string userData;
private string protocolDataUnitType = "11";
private string MR = "00";
private string PID = "00";
private string DCS = "08";
private string VP = "C4";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (comboBox1.SelectedItem.ToString() == "GBtoUCS2")
{
string userData;
userData = string.Empty;
//数据部分字符串赋空值,以便写入编码
Encoding encodingUTF = Encoding.BigEndianUnicode;
//Encoding.BigEndianUnicode可直接完成数据编码与高低字节的交换,若用Unicode需再加高低字节的互换
byte[] Bytes = encodingUTF.GetBytes(textBox1.Text);
for (int i = 0; i < Bytes.Length; i++)
{
userData += BitConverter.ToString(Bytes, i, 1);
}
userDataLenghth = (userData.Length / 2).ToString("X2"); //完成UDL计算与赋值(1个8位组)
textBox2.Text = userData;
}
}
private void button2_Click(object sender, EventArgs e)
{
ud(textBox5.Text);
textBox6.Text = sca(textBox3.Text) + protocolDataUnitType + MR + da(textBox4.Text) + PID + DCS + VP+userDataLenghth+userData;
}
private string sca(string value)
{
string serviceCenterAddress;
if (value == null || value.Length == 0) //号码为空 短消息中心号码为空 则SCA部分编码为”00”
{
serviceCenterAddress = "00";
}
else
{
if (value[0] == '+') //去掉服务中心前导加号
{
value = value.TrimStart('+');
}
if (value.Substring(0, 2) != "86")
{
value = "86" + value; //服务中心加86
}
value = "91" + ParityChange(value); //国际码
serviceCenterAddress = (value.Length / 2).ToString("X2") + value;
}
return serviceCenterAddress;
}
private string da(string value)
{
string destinationAddress;
if (value == null || value.Length == 0) //号码为空
{
destinationAddress = "00";
}
else
{
if (value[0] == '+')
{
value = value.TrimStart('+');
}
if (value.Substring(0, 2) == "86")
{
value = value.TrimStart('8', '6');
}
int len = value.Length;
value = ParityChange(value);
destinationAddress = len.ToString("X2") + "81" + value;
}
return destinationAddress;
}
private string ParityChange(string str)
{
string result = string.Empty;
if (str.Length % 2 != 0) //奇字符串 补F
{
str += "F";
}
for (int i = 0; i < str.Length; i += 2)
{
result += str[i + 1];
result += str;
}
return result;
}
private void ud(string value)
{
userData = string.Empty;
//数据部分字符串赋空值,以便写入编码
Encoding encodingUTF = Encoding.BigEndianUnicode;
//Encoding.BigEndianUnicode可直接完成数据编码与高低字节的交换,若用Unicode需再加高低字节的互换
byte[] Bytes = encodingUTF.GetBytes(value);
for (int i = 0; i < Bytes.Length; i++)
{
userData += BitConverter.ToString(Bytes, i, 1);
}
userDataLenghth = (userData.Length / 2).ToString("X2"); //完成UDL计算与赋值(1个8位组)
}
}
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
你熬了10碗粥,别人一桶水倒进去,淘走90碗,剩下10碗给你,你看似没亏,其实你那10碗已经没有之前的裹腹了,人家的一桶水换90碗,继续卖。说白了,通货膨胀就是,你的钱是挣来的,他的钱是印来的,掺和在一起,你的钱就贬值了。
|