tpitale
Confusing encoding variation in binary characters \f and 0x0c are the same?
I’m performing an :erlang.binary_to_term encoding (the term is {:entitlements, 1396429}). As a result, this comes out to be <<131, 104, 2, 100, 0, 12, 101, 110, 116, 105, 116, 108, 101, 109, 101, 110, 116, 115, 98, 0, 21, 78, 205>>.
If I put this into something like redis, it is encoded to look like (what I think is) an ASCII string: "\x83h\x02d\x00\x0centitlementsb\x00\x15N\xcd". I can get something similar by using IO.inspect(binaries: :as_strings). But it’s not exactly the same as what redis has. IO inspect returns: "\x83h\x02d\0\fentitlementsb\0\x15N\xCD".
One difference, is the \f vs redis having \x0c. These are both <<12>>. If you start iex and put in <<12>> it returns \f. And ?\f is 12, and 0x0c is also 12.
So, I guess my questions:
- How does elixir pick which format
\fvs\x0cto print out? - How can I pick which format to use, if at all?
- For bonus points: How do I get the value that
IO.inspectprints without sending it tostdio?
Any information is help, thank you!
Trending in Questions
Other Trending 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
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security










First Post!
hauleth
inspect/1