BitStream.BitIO.BitWriter.WriteByte C# (CSharp) Method

WriteByte() public method

public WriteByte ( byte b, int bitLength = 8 ) : void
b byte
bitLength int
return void
        public void WriteByte(byte b, int bitLength=8)
        {
            var bin = Convert.ToString(b, 2);
            AppendBinString(bin, bitLength);
        }

Usage Example

Beispiel #1
0
        public byte[] Encode(string text)
        {
            var len = text.Length * 7 + 24;

            var writer = new BitWriter(len);
            writer.WriteByte(2);
            writer.WriteInt(text.Length, 16);

            for (int i = 0; i < text.Length; i++)
            {
                var b = Convert.ToByte(text[i]);
                writer.WriteByte(b, 7);
            }

            return writer.GetBytes();
        }
All Usage Examples Of BitStream.BitIO.BitWriter::WriteByte