[erlang-questions] Simle Erlang Question (Binary "String" to Erlang "String")

David Lloyd lloy0076@REDACTED
Sun Sep 28 02:33:35 CEST 2008


Hello,

I've pasted an erlang shell session below but I'll ask my question here 
so you don't have to wade through it if you don't want to.

I have gotten this:

  3> {ok, File}=file:read_file("hello.b64").
  {ok,<<"SGVsbG8sIHdvcmxkIQ==\n">>}

I want to make File into an Erlang string so that effectively if I asked 
for its value in the shell I'd get something like this:

  4> File.
  "SGVsbG8sIHdvcmxkIQ==\n"

I've been reading "Programming Erlang" by Joe Armstrong, the online R12B 
reference manual, the "Stdlib" documentation and "Concurrent Programming 
in Erlang" (or at least the parts that are publically released) in which 
Joe Armstrong is one of the authors.

However, I can't quite work out the right section or way to do what I'd 
like to do nor can I figure out a query to put to google that doesn't 
come back with too many answers (it seems erlang string and bit are 
quite common).

Any pointers?

DSL

---

bash-3.2$ erl
Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] 
[kernel-poll:false]

Eshell V5.5.5  (abort with ^G)
ok
8> bash-3.2$ erl
Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] 
[kernel-poll:false]

Eshell V5.5.5  (abort with ^G)
1> {ok, File} = file:read_file("hello.b64").
{ok,<<"SGVsbG8sIHdvcmxkIQ==\n">>}
2> File.
<<"SGVsbG8sIHdvcmxkIQ==\n">>




More information about the erlang-questions mailing list