字符串 string str="尀尀u8f6f尀尀u4ef6"; 如何转换为汉字呢。

2025-03-07 14:50:29
推荐回答(2个)
回答1:

private string ConvertUniCode2Hanzi(string unicode)
{
string o = string.Empty;
try
{

string cd2 = unicode;
int len = cd2.Length / 2;
byte[] b = new byte[len];
for (int i = 0; i < cd2.Length; i += 2)
{
string bi = cd2.Substring(i, 2);
b[i / 2] = (byte)Convert.ToInt32(bi, 16);
}
o = Encoding.Unicode.GetString(b).ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return o;
}

回答2:

.......