I wanted to remove those <<"\r\n">> characters from lines read from a file, and know that my line are made of 29 characters (reading date strings).
So with this function:
shrinkbin(Data, Size) ->
<<Data:Size/binary-unit:8>>.
I can do:
node> test:shrinkbin(<<"Sun Jun 10 15:20:53 CEST 2007\r\n">>, 29).
<<"Sun Jun 10 15:20:53 CEST 2007">>.
That's it !
1 comment:
I think You need to capitalize size in the example.
shrinkbin(Data, Size) ->
<<Data:Size/binary-unit:8>>.
Post a Comment