/// <summary> /// Unpack the string 'x' (network order byte format) into object. /// </summary> public static object Unpack(string x, int n) { x = Util.StringPad(x, n); byte[] b = new byte[n]; for (int i = 0; i < x.Length; i++) { b[i] = (byte)x[i]; } if (b.Length == 1) { return(BStruct.ToInt1(b, 0)); } if (b.Length == 2) { return(BStruct.ToInt2(b, 0)); } if (b.Length == 4) { return(BStruct.ToInt4(b, 0)); } if (b.Length == 8) { return(BStruct.ToInt8(b, 0)); } return(null); }
private static object DecodeInt2(string x, int startIndex, out int endIndex) { startIndex += 1; endIndex = startIndex + 2; return(BStruct.ToInt2(Util.StringBytes(x.Substring(startIndex, 2)), 0)); }