blob: 51bd86afc4f92c3081ce9354c45c9692f81867ea [file] [log] [blame]
-compile(export_all).
msg(Fmt, Args) ->
M1 = io_lib:format(Fmt, Args),
M2 = re:replace(M1, <<"\r">>, <<"\\\\r">>, [global]),
M3 = re:replace(M2, <<"\n">>, <<"\\\\n">>, [global]),
M4 = re:replace(M3, <<"\t">>, <<"\\\\t">>, [global]),
iolist_to_binary(M4).
hex(Bin) when is_binary(Bin) ->
H1 = [io_lib:format("16#~2.16.0B",[X]) || <<X:8>> <= Bin],
H2 = string:join(H1, ", "),
lists:flatten(io_lib:format("<<~s>>", [lists:flatten(H2)])).
dec(V) ->
jiffy:decode(V).
enc(V) ->
iolist_to_binary(jiffy:encode(V)).
enc(V, Opts) ->
iolist_to_binary(jiffy:encode(V, Opts)).