private string ConvertFromHexadecimal(string hexadecimalText)
{
if (hexadecimalText.Length % 2 != 0)
{
throw new ArgumentException("输入的十六进制字符串长度必须为偶数");
}
byte[] bytes = new byte[hexadecimalText.Length / 2];
for (int i = 0; i < bytes.Length; i++)
{
bytes = Convert.ToByte(hexadecimalText.Substring(i * 2, 2), 16);
}
// 使用GBK编码将字节数组转换为文本
return Encoding.GetEncoding("GBK").GetString(bytes);
}
b801b483-16a7-46dc-8c62-fd5b712f89da.png (11.74 KB, 下载次数: 1)
private byte[] ConvertFromHexadecimal(string hexadecimalText)
{
if (hexadecimalText.Length % 2 != 0)
{
throw new ArgumentException("输入的十六进制字符串长度必须为偶数");
}
byte[] bytes = new byte[hexadecimalText.Length / 2];
for (int i = 0; i < bytes.Length; i++)
{
bytes = Convert.ToByte(hexadecimalText.Substring(i * 2, 2), 16);
}
return bytes;
// 使用GBK编码将字节数组转换为文本
//return Encoding.GetEncoding("GBK").GetString(bytes);
}
欢迎光临 精易论坛 (https://125.confly.eu.org/) | Powered by Discuz! X3.4 |