.Net 8-bit Encoding

后端 未结 5 2111
春和景丽
春和景丽 2020-12-19 13:14

I\'m working on serial port, transmitting and receiving data to some hardware at 8bit data. I would like to store it as string to facilitate comparison, and preset data are

5条回答
  •  醉话见心
    2020-12-19 13:35

    You could use base64 encoding to convert from byte to string and back. No problems with code pages or weird characters that way, and it'll be more space-efficient than hex.

    byte[] toEncode; 
    string encoded = System.Convert.ToBase64String(toEncode);
    

提交回复
热议问题