Tyrn

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

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

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

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?

Last Post!

jeremyjh

jeremyjh

You are right of course, I don’t know what I was thinking with an erlang library.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement