Convert char string to array of numbers

Is there a command I can run to convert a char into an array of numbers? E.g. say I see the logs print this in a failed test result.

 ~c"\n"

How to convert to array of numbers?

This made me recall a semi-recent convo about this and found this thread though it’s your thread :sweat_smile:

If you’re not talking tests, you can pass the charlists: :as_lists) option to either dbg or IO.inspect:

iex(1)> IO.inspect(~c"hey there", charlists: :as_lists) 
[104, 101, 121, 32, 116, 104, 101, 114, 101]
~c"hey there"

There is also this recent thread. TL;DR, if you want it IEx:

IEx.configure(inspect: [charlists: :as_lists])

Though there is a bunch of random interesting stuff in that thread.

While the above is correct it‘s not a conversion. The data is the exact same for both. It‘s the formatting to a readable representation, which is different.

It already is a list of numbers. You’ll have to clarify what do you mean by “array”.