/// <summary> /// Reads an integer as size, skips a byte and reads the string itself /// </summary> /// <returns></returns> public static string GpReadStringIntByte(this IReadable data) { var length = data.ReadInt32LE() - 1; data.ReadByte(); return(data.GpReadString(length)); }
/// <summary> /// Reads a byte as size and the string itself. /// Additionally it is ensured the specified amount of bytes is read. /// </summary> /// <param name="data">the data to read from.</param> /// <param name="length">the amount of bytes to read</param> /// <returns></returns> public static string GpReadStringByteLength(this IReadable data, int length) { var stringLength = data.ReadByte(); var s = data.GpReadString(stringLength); if (stringLength < length) { data.Skip(length - stringLength); } return(s); }
/// <summary> /// Skips an integer (4byte) and reads a string using /// a bytesize /// </summary> /// <returns></returns> public static string GpReadStringIntUnused(this IReadable data) { data.Skip(4); return(data.GpReadString(data.ReadByte())); }
/// <summary> /// Reads an integer as size, and then the string itself /// </summary> /// <returns></returns> public static string GpReadStringInt(this IReadable data) { return(data.GpReadString(data.ReadInt32LE())); }
/// <summary> /// Reads an integer as size, and then the string itself /// </summary> /// <returns></returns> public static string GpReadStringInt(this IReadable data, string encoding) { return(data.GpReadString(data.ReadInt32LE(), encoding)); }