string转Byte[]
string str = "Hello World";
byte[] byteArray = Encoding.UTF8.GetBytes(str);
Byte[]转string
参考链接:https://www.python100.com/html/53C7X14UU3EW.html
参考链接:https://blog.csdn.net/godwe/article/details/123000423
// UTF8
string str = "Hello world!";
byte[] bytes = Encoding.UTF8.GetBytes(str);
string result = Encoding.UTF8.GetString(bytes);
// GBK
string str = "Hello world!";
byte[] bytes = Encoding.GetEncoding("GBK").GetBytes(str);
string result = Encoding.GetEncoding("GBK").GetString(bytes);
标签:转换,string,Encoding,UTF8,bytes,Sting,str,Byte
From: https://www.cnblogs.com/fusio/p/17671977.html