Christian S chsu79@REDACTED
Tue Nov 29 17:26:09 CET 2005

This is mostly a me-too message. I too use binaries for strings often,
and feel the lack of a 'binaries' module (like there is a 'string' and
a 'lists' module that are useful for the usual way to do strings). I
feel a jungerl lib idea growing.

So this question goes out to all readers:
What interfaces do you chose to use for your utility functions?

Personally, I use something like this frequently:

skip(<<"abc:def">>, $:) to get <<"def">>

piks(<<"abc:def">>, $:) to get <<"abc">>

divide(<<"abc:def">>, $:) to get {<<"abc">>, <<"def">>} (like joe's
but only single-char divider)

match(Bin, RE) -> regexp:match(binary_to_list(Bin), RE).

part(<<"abcdef">>, 3, 2) -> <<"cd">>.

And I implement the special cases differently every time i reinvent
the code. It is not much code to implement, but a shared code base
means we all call these functions the same thing.

Using binaries as octet-strings always make me worry about code spaces
that do not fit as super sets of ASCII in 256 code points.
utf8-versions of the above examples seem like at least twice the job
to write, so i never bothered.

If I could reach the web on ports other than 80 and 8080 I would have
pointed to a erlang wiki page.

More information about the erlang-questions mailing list