C# SerialPort  发送中文 都是乱码 ,要怎么解决啊 我发送中文 为繁体中文!!!谢谢

解决方案 »

  1.   

    设置一下字符编码:UTF8或者GB2312
      

  2.   

    Encoding.UTF8.GetString(byte[])  试试吧
      

  3.   

    给个地址
    http://www.8844.com/html/IT_jiaocheng/ruanjian/sheji_kaifa/biancheng/biancheng_yuyan/dotnet/2011/05-26/357396.html
      

  4.   


    #region 串口信号接收
    private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
    {
        //当我发送“你好,中国!”,希望弹出文本框显示“你好,中国!”
        MessageBox.Show();
    }
    #endregion大牛们,帮忙……
    messagebox.show()里面怎么写??
    八楼的asp.net表示看得有鸭梨……
      

  5.   

      BPressListening = true;
      int n = SPPress.BytesToRead;
      byte[] buf = new byte[n];//声明一个临时数组存储当前来的串口数据   
      SPPress.Read(buf, 0, n);//读取缓冲数据 
      把buf转换成string
      messagebox.show(string);
      

  6.   

    Encoding unicode = Encoding.Unicode;
                    Encoding big5 = Encoding.GetEncoding("big5");
    byte[] unicodeBytes = Encoding.Convert(big5, unicode, buffer);
                    char[] cResult = unicode.GetChars(unicodeBytes);
                    String strResult = new String(cResult);
    buffer是接收缓冲区字节数组
      

  7.   

    C# codeEncoding unicode = Encoding.Unicode;
                    Encoding big5 = Encoding.GetEncoding("big5");
    byte[] unicodeBytes = Encoding.Convert(big5, unicode, buffer);
                    char[] cResult = unicode.GetChars(unicodeBytes);
                    String strResult = new String(cResult);
      

  8.   

    首先是这位哥们的,红色标记地方是神马意思啊???我注释后运行结果是:System.Byte[]
    求解释啊?????
      

  9.   

    String temp = null;
    Encoding chs = Encoding.GetEncoding("gb2312");
    temp = chs.GetString(bytes, 0, bytes.Length);
    return temp;
    bytes是字节数组(byte[])