三川BBS's Archiver

二十郎 发表于 2008-9-18 09:05

传一个AscII 和 String 互换的软件

只是自己用的。如果 输入字符串点 AscII==>String 会出错地。


代码==================《》

  public partial class ASCtools : Form
    {
        public ASCtools()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length > 0)
            {
                string input = textBox1.Text;
                string output = null;
                byte[] bt = Encoding.Default.GetBytes(input);
                for (int i = 0; i < bt.Length; i++)
                {
                    output += bt[i].ToString() + ",";
                }
                textBox2.Text = output;
                Encoding ec=Encoding.GetEncoding("GB2312");
                lb2312.Text = ec.GetString(bt);
                ec = Encoding.GetEncoding("GBK");
                lbGBK.Text = ec.GetString(bt);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length > 0)
            {
                string[] st = textBox1.Text.Split(',');
                byte[] bt = new byte[st.Length];
                for (int i = 0; i < st.Length; i++)
                {
                    bt[i] = Convert.ToByte(st[i]);
                }
                textBox2.Text = textBox1.Text;
                Encoding ec = Encoding.GetEncoding("GB2312");
                lb2312.Text = ec.GetString(bt);
                ec = Encoding.GetEncoding("GBK");
                lbGBK.Text = ec.GetString(bt);
            }
        }
    }

冷楚楚 发表于 2008-9-22 11:32

看不懂啊。。。

页: [1]
       

Powered by 三川BBS Archiver 6.1.0  © 2001-2007 本SEO插件由网络人站长论坛出品