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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








