public static string GetGB2312(string str)
{
StringBuilder strResult = new StringBuilder();
Byte[] encodedBytes = new byte[str.Length * 2];
int iCount = Encoding.GetEncoding("gb2312").GetBytes(str, 0, str.Length, encodedBytes, 0);
foreach (Byte b in encodedBytes)
{
strResult.Append("%" + Convert.ToString(b, 16).ToUpper());
}
return strResult.ToString();
}
CSharp
最后修改于 2010-12-27 10:33:30