From 29a347ffd408c68861a914db4efc75d8ea20a762 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Tue, 17 Apr 2018 15:22:15 +0200 Subject: stdlib: Introduce characters limit of formated strings Inspiration from module lager_format. Also some improvements of Unicode handling. io_lib:format/3 and io_lib:fwrite/3 are new functions. The representation of the options is a list, but we are considering using a map instead. If we change, it will happen after Erlang/OTP 21.0-rc1 is released. --- lib/stdlib/doc/src/io_lib.xml | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'lib/stdlib/doc/src') diff --git a/lib/stdlib/doc/src/io_lib.xml b/lib/stdlib/doc/src/io_lib.xml index bc1d77ac83..4a2b425e8e 100644 --- a/lib/stdlib/doc/src/io_lib.xml +++ b/lib/stdlib/doc/src/io_lib.xml @@ -4,7 +4,7 @@
- 19962017 + 19962018 Ericsson AB. All Rights Reserved. @@ -51,6 +51,9 @@ fread/3.

+ + + @@ -152,6 +155,27 @@ + + + + Write formatted output. + +

Returns a character list that represents Data + formatted in accordance with Format in + the same way as + fwrite/2 and + format/2, + but takes an extra argument, a list of options.

+

Available options:

+ + CharsLimit + +

A soft limit on the number of characters returned.

+
+
+
+
+ Read formatted input. @@ -361,17 +385,24 @@ Write a term.

Returns a character list that represents Term. - Argument Depth controls the depth of the + Option Depth controls the depth of the structures written. When the specified depth is reached, everything below this level is replaced by "...". Depth defaults to -1, which means - no limitation.

+ no limitation. Option CharsLimit puts a + soft limit on the number of characters returned. When the + number of characters is reached, remaining structures are + replaced by "...". CharsLimit + defaults to -1, which means no limit on the number of + characters returned.

Example:

 1> lists:flatten(io_lib:write({1,[2],[3],[4,5],6,7,8,9})).
 "{1,[2],[3],[4,5],6,7,8,9}"
 2> lists:flatten(io_lib:write({1,[2],[3],[4,5],6,7,8,9}, 5)).
-"{1,[2],[3],[...],...}"
+"{1,[2],[3],[...],...}" +3> lists:flatten(io_lib:write({[1,2,3],[4,5],6,7,8,9}, [{chars_limit,20}])). +"{[1,2|...],[4|...],...}"
-- cgit v1.2.3