/// <summary> /// 字节流解码。 /// </summary> public static string ToString(byte[] buffer, int startIndex, int length, CmppEncoding encoding) { switch (encoding) { case CmppEncoding.GBK: return Encoding.GetEncoding("gb2312").GetString(buffer, startIndex, length); case CmppEncoding.ASCII: return Encoding.ASCII.GetString(buffer, startIndex, length); case CmppEncoding.UCS2: return Encoding.BigEndianUnicode.GetString(buffer, startIndex, length); default: return ""; } }
/// <summary> /// 字节流解码。 /// </summary> public static string ToString(byte[] buffer, int startIndex, int length, CmppEncoding encoding) { switch (encoding) { case CmppEncoding.GBK: return(Encoding.GetEncoding("gb2312").GetString(buffer, startIndex, length)); case CmppEncoding.ASCII: return(Encoding.ASCII.GetString(buffer, startIndex, length)); case CmppEncoding.UCS2: return(Encoding.BigEndianUnicode.GetString(buffer, startIndex, length)); default: return(""); } }