C#如何将字符串转换成UTF8编码

2025-02-25 06:05:01
推荐回答(1个)
回答1:

using System.Text;

byte[] buffer = Encoding.GetEncoding("utf-8").GetBytes("中国");
string str = "";

foreach (byte b in buffer) str += string.Format("%{0:X}", b);