admin管理员组

文章数量:1531792

2024年6月14日发(作者:)

{

("%25u");

(ba[i + 1].ToString("X2"));

(ba[i].ToString("X2"));

}

return ng();

}

7、将Unicode编码转换为汉字字符串

///

/// 汉字转换为Unicode编码

///

/// 要编码的汉字字符串

/// Unicode编码的的字符串

public static string ToUnicode(string str)

{

byte[] bts = es(str);

string r = "";

for (int i = 0; i < ; i += 2) r += "u" + bts[i + 1].ToString("x").PadLeft(2, '0') + bts[i].ToString("x").PadLeft(2, '0');

return r;

}

///

/// 将Unicode编码转换为汉字字符串

///

/// Unicode编码字符串

/// 汉字字符串

public static string ToGB2312(string str)

{

string r = "";

MatchCollection mc = s(str, @"u([w]{2})([w]{2})", ed | Case);

byte[] bts = new byte[2];

foreach (Match m in mc)

{

bts[0] = (byte)([2].Value, ber);

bts[1] = (byte)([1].Value, ber);

r += ing(bts);

}

return r;

}

本文标签: 编码解码字符串实现相关