Skip to content

tabrath/BinaryEncoding

Repository files navigation

BinaryEncoding

Travis Appveyor CircleCI Codecov Version Downloads Forks Stars License Frameworks Platforms

BinaryEncoding simplifies the encoding of numbers to BigEndian, LittleEndian and Varint to byte arrays.

API

To set values to an array of bytes:

Binary.BigEndian.Set(bytes, offset, value);
Binary.LittleEndian.Set(bytes, offset, value);
Binary.Varint.Write(bytes, offset, value);

Extension methods are provided for retrieving the bytes:

Binary.BigEndian.GetBytes(value);
Binary.LittleEndian.GetBytes(value);
Binary.Varint.GetBytes(value);

Also, for converting bytes to numbers:

Binary.BigEndian.GetInt16(bytes, offset);
Binary.BigEndian.GetInt32(bytes, offset);
Binary.BigEndian.GetInt64(bytes, offset);
Binary.BigEndian.GetUInt16(bytes, offset);
Binary.BigEndian.GetUInt32(bytes, offset);
Binary.BigEndian.GetUInt64(bytes, offset);
Binary.LittleEndian.GetInt16(bytes, offset);
Binary.LittleEndian.GetInt32(bytes, offset);
Binary.LittleEndian.GetInt64(bytes, offset);
Binary.LittleEndian.GetUInt16(bytes, offset);
Binary.LittleEndian.GetUInt32(bytes, offset);
Binary.LittleEndian.GetUInt64(bytes, offset);

// varint, returns number of bytes consumed
// value can be short, ushort, int, uint, long, ulong
Binary.Varint.Read(bytes, out value);

.. more to come

About

Easy encoding of numbers to BigEndian, LittleEndian and Varint.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages