Tyrn
Elixir string representation
Using Python interaction via ErlPort I discovered that ordinary Elixir strings are Python 3 b"" strings. It is not always convenient. You have to .decode() them in your Python code. Is there a way to convert Elixir strings before passing them as arguments to remote functions?
Most Liked
NobbZ
Yes.
This is how it always works, everywhere.
When you use some sort of FFI, you will always also write wrappers that do type conversion, or mapping at least.
NobbZ
Elixir strings are binary data.
"a" is not different than <<65>>.
So erlport can’t know if you want a u"" string or a b"" string (erlport doesn’t even know there is a difference on the python side).
You have to decide on your own on the receiving script which one you need.
NobbZ
Erlport is just mapping erlang terms to their most straight forward target representation. As an erlang library its not necessarily aware of elixir strings. And even if it were, how should it decide whether you want to receive "a" or b"a" on the other end?
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
- #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
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








