KevinDaSilvaS
How to transform bitstring into iodata?
Hi everyone Im facing problems with bitstrings I’m open a folder containing files and have to encode it with Huffman algorithm(huffman | Hex), after encoding I have to save it into an encripted file, but the Huffman.encode functions returns an encoded bitstring and not a binary so I cant save it due to not being an iodata, does anyone have a hint on how to solve this issue
PS I’m using File.write to save a file:
def save_file({encoded, _keys}, filepath, filename) do
IO.inspect(is_bitstring(encoded))
IO.inspect(encoded)
path = filepath <> “/” <> filename <> “.txt”
File.touch!(path)
File.write(path, encoded)
end
Thank you!
First Post!
al2o3cr
The biggest difference between a bitstring and a binary is that the former isn’t evenly divisible into bytes - you need to decide how to pad your data (leading zeros? trailing zeros?) to a multiple of 8 bits.







