/// <summary> /// 将中文汉字转为字节数组 /// </summary> /// <param name="chineseStr"></param> /// <returns></returns> public static byte[] parseChineseToByte(string chineseStr) { Encoding fromEcoding = Encoding.GetEncoding("UTF-8");//返回utf-8的编码 Encoding toEcoding = Encoding.GetEncoding("gb2312"); byte[] fromBytes = fromEcoding.GetBytes(chineseStr); byte[] tobytes = Encoding.Convert(fromEcoding, toEcoding, fromBytes);//将字节数组从一种编码转换为另一种编码 return tobytes; }
标签:编码,中文,字节,Encoding,数组,fromEcoding,byte From: https://www.cnblogs.com/dtsd/p/17605771.html