From 97ab480df55cf574ab42a87b6927ef5bba83000e Mon Sep 17 00:00:00 2001 From: Patrik Nyblom Date: Mon, 10 May 2010 16:27:58 +0200 Subject: Add documentation for binary module Correct behaviour of copy/2 witn 0 copies. --- erts/doc/src/erlang.xml | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index cd9bb85f5c..e90160dfd7 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -252,6 +252,54 @@ iolist() = [char() | binary() | iolist()] "Erlang" + + binary_part(Subject, PosLen) -> binary() + Extracts a part of a binary + + Subject = binary() + PosLen = {Start,Length} + Start = int() + Length = int() + + +

Extracts the part of the binary described by PosLen.

+ +

Negative length can be used to extract bytes at the end of a binary:

+ + +1> Bin = <<1,2,3,4,5,6,7,8,9,10>>. +2> binary_part(Bin,{byte_size(Bin), -5)). +<<6,7,8,9,10>> + + +

If PosLen in any way references outside the binary, a badarg exception is raised.

+ +

Start is zero-based, i.e:

+ +1> Bin = <<1,2,3>> +2> binary_part(Bin,{0,2}). +<<1,2>> + + +

See the STDLIB module binary for details about the PosLen semantics.

+ +

Allowed in guard tests.

+
+
+ + binary_part(Subject, Start, Length) -> binary() + Extracts a part of a binary + + Subject = binary() + Start = int() + Length = int() + + +

The same as binary_part(Subject, {Pos, Len}).

+ +

Allowed in guard tests.

+
+
binary_to_atom(Binary, Encoding) -> atom() Convert from text representation to an atom @@ -318,6 +366,11 @@ iolist() = [char() | binary() | iolist()] corresponding to the bytes from position Start to position Stop in Binary. Positions in the binary are numbered starting from 1.

+ +

This functions indexing style of using one-based indices for + binaries is deprecated. New code should use the functions in + the STDLIB module binary instead. They consequently + use the same (zero-based) style of indexing.

-- cgit v1.2.3