[erlang-questions] List troubles
Raimo Niskanen
raimo+erlang-questions@REDACTED
Thu Nov 10 08:22:45 CET 2016
On Wed, Nov 09, 2016 at 08:26:30PM +0000, Thomas Elsgaard wrote:
> Thanks! I tried many other things, but you solved it, thanks! Now I also
> learned something new today ;-)
It might actually be this one you need:
2> unicode:characters_to_list([<<"A">>,"4",<<"B">>,"c",<<"d">>]).
"A4Bcd"
or
3> unicode:characters_to_binary([<<"A">>,"4",<<"B">>,"c",<<"d">>]).
<<"A4Bcd">>
if you should want an UTF-8 binary as the result.
iolist_to_binary assumes ISO Latin-1 i.e ISO 8859-1 character encoding.
The unicode module presumes UTF-8 and enables the choice of most Unicode
encodings as well as Latin-1 as well as the choice of outputting a binary
or a list.
Side not: the term "flattening a list" suggests a list of any type terms.
For this task there are functions in the lists module but they flatten
just lists and does not convert a contained binary.
>
> Thomas
>
> On Wed, 9 Nov 2016 at 20:50 Brujo Benavides <
> fernando.benavides@REDACTED> wrote:
>
> > Have you tried iolist_to_binary ?
> >
> > 1> iolist_to_binary([<<"A">>,"4",<<"B">>,"c",<<"d">>]).
> > <<"A4Bcd">>
> > 2> binary_to_list(v(-1)).
> > "A4Bcd"
> > 3>
> >
> > On Nov 9, 2016, at 16:48, Thomas Elsgaard <thomas.elsgaard@REDACTED>
> > wrote:
> >
> > Hi
> >
> > I am having some difficulties by flattening a list which looks like this:
> >
> > [<<"A">>,"4",<<"B">>,"c",<<"d">>]
> >
> > After flattening, it should look like this: A4Bcd
> >
> > Any good ways to do this ?
> >
> > Thomas
> >
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> >
> >
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list