1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
[;1m-spec term_to_binary(Term, Options) -> ext_binary()[0m
[;1m when[0m
[;1m Term :: term(),[0m
[;1m Options ::[0m
[;1m [compressed |[0m
[;1m {compressed, Level :: 0..9} |[0m
[;1m deterministic |[0m
[;1m {minor_version, Version :: 0..2}].[0m
Returns a binary data object that is the result of encoding [;;4mTerm[0m
according to the Erlang external term format.
If option [;;4mcompressed[0m is provided, the external term format is
compressed. The compressed format is automatically recognized by [;;4m[0m
[;;4mbinary_to_term/1[0m as from Erlang/OTP R7B.
A compression level can be specified by giving option [;;4m[0m
[;;4m{compressed, Level}[0m. [;;4mLevel[0m is an integer with range 0..9,
where:
• [;;4m0[0m - No compression is done (it is the same as giving no [;;4m[0m
[;;4mcompressed[0m option).
• [;;4m1[0m - Takes least time but may not compress as well as the
higher levels.
• [;;4m6[0m - Default level when option [;;4mcompressed[0m is provided.
• [;;4m9[0m - Takes most time and tries to produce a smaller result.
Notice "tries" in the preceding sentence; depending on the
input term, level 9 compression either does or does not
produce a smaller result than level 1 compression.
Option [;;4m{minor_version, Version}[0m can be used to control some
encoding details. This option was introduced in Erlang/OTP R11B-4.
The valid values for [;;4mVersion[0m are:
[;;4m[;;4m0[0m[0m:
Floats are encoded using a textual representation. This option
is useful to ensure that releases before Erlang/OTP R11B-4 can
decode resulting binary.
This version encode atoms that can be represented by a latin1
string using latin1 encoding while only atoms that cannot be
represented by latin1 are encoded using utf8.
[;;4m[;;4m1[0m[0m:
This is as of Erlang/OTP 17.0 the default. It forces any
floats in the term to be encoded in a more space-efficient and
exact way (namely in the 64-bit IEEE format, rather than
converted to a textual representation). As from Erlang/OTP
R11B-4, [;;4mbinary_to_term/1[0m can decode this representation.
This version encode atoms that can be represented by a latin1
string using latin1 encoding while only atoms that cannot be
represented by latin1 are encoded using utf8.
[;;4m[;;4m2[0m[0m:
Drops usage of the latin1 atom encoding and unconditionally
use utf8 encoding for all atoms. Erlang/OTP systems as of R16B
can decode this representation.
Note:
In Erlang/OTP 26, the default [;;4mminor_version[0m is planned
to change from 1 to 2. See Upcoming Potential
Incompatibilities .
Option [;;4mdeterministic[0m (introduced in OTP 24.1) can be used to
ensure that within the same major release of Erlang/OTP, the same
encoded representation is returned for the same term. There is
still no guarantee that the encoded representation remains the
same between major releases of Erlang/OTP.
See also [;;4mbinary_to_term/1[0m.
|