From 675b8108486919739dc2e213587489c0daab80cb Mon Sep 17 00:00:00 2001
From: Hans Bolinder
The following control sequences are available:
+ single character (currently onlyThe following control sequences are available:
-2> io:fwrite("|~10.5c|~-10.5c|~5c|~n", [$a, $b, $c]). +1> io:fwrite("|~10.5c|~-10.5c|~5c|~n", [$a, $b, $c]). | aaaaa|bbbbb |ccccc| ok
If the Unicode translation modifier (
-1> io:fwrite("~tc~n",[1024]). +2> io:fwrite("~tc~n",[1024]). \x{400} ok -2> io:fwrite("~c~n",[1024]). +3> io:fwrite("~c~n",[1024]). ^@ ok@@ -462,20 +463,20 @@ ok
This format can be used for printing any object and truncating the output so it fits a specified field:
-3> io:fwrite("|~10w|~n", [{hey, hey, hey}]). +1> io:fwrite("|~10w|~n", [{hey, hey, hey}]). |**********| ok -4> io:fwrite("|~10s|~n", [io_lib:write({hey, hey, hey})]). +2> io:fwrite("|~10s|~n", [io_lib:write({hey, hey, hey})]). |{hey,hey,h| -5> io:fwrite("|~-10.8s|~n", [io_lib:write({hey, hey, hey})]). +3> io:fwrite("|~-10.8s|~n", [io_lib:write({hey, hey, hey})]). |{hey,hey | ok
A list with integers larger than 255 is considered an error if the Unicode translation modifier is not given:
-1> io:fwrite("~ts~n",[[1024]]). +4> io:fwrite("~ts~n",[[1024]]). \x{400} ok -2> io:fwrite("~s~n",[[1024]]). +5> io:fwrite("~s~n",[[1024]]). ** exception exit: {badarg,[{io,format,[<0.26.0>,"~s~n",[[1024]]]}, ...
-5> T = [{attributes,[[{id,age,1.50000},{mode,explicit}, +1> T = [{attributes,[[{id,age,1.50000},{mode,explicit}, {typename,"INTEGER"}], [{id,cho},{mode,explicit},{typename,'Cho'}]]}, {typename,'Person'},{tag,{'PRIVATE',3}},{mode,implicit}]. ... -6> io:fwrite("~w~n", [T]). +2> io:fwrite("~w~n", [T]). [{attributes,[[{id,age,1.5},{mode,explicit},{typename, [73,78,84,69,71,69,82]}],[{id,cho},{mode,explicit},{typena me,'Cho'}]]},{typename,'Person'},{tag,{'PRIVATE',3}},{mode ,implicit}] ok -7> io:fwrite("~62p~n", [T]). +3> io:fwrite("~62p~n", [T]). [{attributes,[[{id,age,1.5}, {mode,explicit}, {typename,"INTEGER"}], @@ -522,7 +523,7 @@ ok
-8> io:fwrite("Here T = ~62p~n", [T]). +4> io:fwrite("Here T = ~62p~n", [T]). Here T = [{attributes,[[{id,age,1.5}, {mode,explicit}, {typename,"INTEGER"}], @@ -532,6 +533,18 @@ Here T = [{attributes,[[{id,age,1.5}, {typename,'Person'}, {tag,{'PRIVATE',3}}, {mode,implicit}] +ok+
When the modifier
+5> S = [{a,"a"}, {b, "b"}]. +6> io:fwrite("~15p~n", [S]). +[{a,"a"}, + {b,"b"}] +ok +7> io:fwrite("~15lp~n", [S]). +[{a,[97]}, + {b,[98]}] ok
-9> io:fwrite("~W~n", [T,9]). +8> io:fwrite("~W~n", [T,9]). [{attributes,[[{id,age,1.5},{mode,explicit},{typename,...}], [{id,cho},{mode,...},{...}]]},{typename,'Person'}, {tag,{'PRIVATE',3}},{mode,implicit}] @@ -558,7 +571,7 @@ okare printed. Anything below this depth is replaced with
-10> io:fwrite("~62P~n", [T,9]). +9> io:fwrite("~62P~n", [T,9]). [{attributes,[[{id,age,1.5},{mode,explicit},{typename,...}], [{id,cho},{mode,...},{...}]]}, {typename,'Person'}, @@ -572,13 +585,13 @@ ok10. A leading dash is printed for negative integers.
The precision field selects base. For example:
-11> io:fwrite("~.16B~n", [31]). +1> io:fwrite("~.16B~n", [31]). 1F ok -12> io:fwrite("~.2B~n", [-19]). +2> io:fwrite("~.2B~n", [-19]). -10011 ok -13> io:fwrite("~.36B~n", [5*36+35]). +3> io:fwrite("~.36B~n", [5*36+35]). 5Z ok@@ -590,10 +603,10 @@ ok
The prefix can be a possibly deep list of characters or an atom.
-14> io:fwrite("~X~n", [31,"10#"]). +1> io:fwrite("~X~n", [31,"10#"]). 10#31 ok -15> io:fwrite("~.16X~n", [-31,"0x"]). +2> io:fwrite("~.16X~n", [-31,"0x"]). -0x1F ok@@ -602,10 +615,10 @@ ok
Like
-16> io:fwrite("~.10#~n", [31]). +1> io:fwrite("~.10#~n", [31]). 10#31 ok -17> io:fwrite("~.16#~n", [-31]). +2> io:fwrite("~.16#~n", [-31]). -16#1F ok@@ -639,10 +652,10 @@ ok
If an error occurs, there is no output. For example:
-18> io:fwrite("~s ~w ~i ~w ~c ~n",['abc def', 'abc def', {foo, 1},{foo, 1}, 65]). +1> io:fwrite("~s ~w ~i ~w ~c ~n",['abc def', 'abc def', {foo, 1},{foo, 1}, 65]). abc def 'abc def' {foo,1} A ok -19> io:fwrite("~s", [65]). +2> io:fwrite("~s", [65]). ** exception exit: {badarg,[{io,format,[<0.22.0>,"~s","A"]}, {erl_eval,do_apply,5}, {shell,exprs,6}, -- cgit v1.2.3