[erlang-patches] Enhancement of erl_prettypr
Serge Aleynikov
serge@REDACTED
Tue Oct 16 18:23:12 CEST 2012
Enhancement of erl_prettypr to print binaries in human-readable form.
git fetch git@REDACTED:saleyn/otp.git erl_prettypr
https://github.com/saleyn/otp/compare/erl_prettypr
https://github.com/saleyn/otp/compare/erl_prettypr.patch
Given an abstract syntax form of a binary, such as:
1> Form = erl_syntax:form_list(element(2, erl_parse:parse_exprs(
element(2, erl_scan:string(
"<<84,104,105,115,32,105,115,32,97,32,98,105,110,97,114,121,10>>."))))).
Before applying the patch the output of erl_prettypr:format/1 looks like
this:
2> erl_prettypr:format(Form).
"<<84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 98, 105,\n 110, 97,
114, 121, 10>>"
After applying the patch the output looks like this:
3> erl_prettypr:format(Form).
"<<\"This is a binary\\n\">>"
The human-readable printing occurs only if erl_prettypr finds out that
the binary represents a printable list.
Regards,
Serge
More information about the erlang-patches
mailing list