Can I disable printing lists of small integers as strings in Erlang shell?

前端 未结 7 1025

The Erlang shell \"guesses\" whether a given list is a printable string and prints it that way for convenience. Can this \"convenience\" be disabled?

7条回答
  •  再見小時候
    2020-11-27 21:25

    I don't think you can prevent it. Prepending an atom seems like a kludge - it does alter your original string.

    I typically use lists:flatten(String) to force it to a string - especially the returnvalue of io_lib:format() does not always print as a string. Using lists:flatten() on it makes it one.

    I use the following "C-style":

    sprintf(Format) ->
         sprintf(Format, []).
    sprintf(Format, Args) ->
        lists:flatten(io_lib:format(Format, Args)).
    

提交回复
热议问题