1

How to convert a binary string to BitArray which has 256 characters? to be able to enter the Huffman decoding method

public string Decode(BitArray bits)
    {
        Node current = this.Root;
        string decoded = "";
        foreach (bool bit in bits)
        {
            if (bit)
            {
                if (current.Right != null)
                {
                    current = current.Right;
                }
            }
            else
            {
                if (current.Left != null)
                {
                    current = current.Left;
                }
            }
            if (IsLeaf(current))
            {
                decoded += current.Symbol;
                current = this.Root;
            }
        }
        return decoded;
    }
jjj
  • 1,136
  • 3
  • 18
  • 28
Jodha Buji
  • 13
  • 2
  • my answer was bad, hope this will help you: http://snipd.net/huffman-coding-in-c – online Thomas Nov 06 '15 at 08:33
  • Maybe this can helps you: [Bit Array to String and back to Bit Array](http://stackoverflow.com/questions/14670645/bit-array-to-string-and-back-to-bit-array) or this: [Converting byte array to string and back again in C#](http://stackoverflow.com/questions/1422314/converting-byte-array-to-string-and-back-again-in-c-sharp) – Nahid Bandi Nov 06 '15 at 08:43
  • 1
    What do you call a "binary string"? Binary data encoded in hexadecimal? base64? – Thomas Levesque Nov 06 '15 at 09:08

0 Answers0