Make pretty-print encode control characters in strings as escape sequences rather than as literal bytes, the same way write does it. --- extras.scm | 29 +++++++++++++++++++---------- 1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/extras.scm b/extras.scm index 0e8b144..8cdbf4a 100644 --- a/extras.scm +++ b/extras.scm @@ -343,17 +343,26 @@ (out "\\" (out (##sys#substring obj i j) col))) - (cond ((assq c '((#\tab . "\\t") - (#\newline . "\\n") - (#\return . "\\r"))) - => - (lambda (a) - (let ((col2 + (if (or (char<? c #\x20) + (char=? c #\x7f)) + (loop (fx+ j 1) + (fx+ j 1) + (let ((col2 (out (##sys#substring obj i j) col))) - (loop (fx+ j 1) - (fx+ j 1) - (out (cdr a) col2))))) - (else (loop i (fx+ j 1) col))))) + (cond ((assq c '((#\tab . "\\t") + (#\newline . "\\n") + (#\return . "\\r") + (#\vtab . "\\v") + (#\page . "\\f") + (#\alarm . "\\b"))) + => + (lambda (a) + (out (cdr a) col2))) + (else + (out (number->string (char->integer c) 16) + (out (if (char<? c #\x10) "0" "") + (out "\\x" col2))))))) + (loop i (fx+ j 1) col)))) (out "\"" (out (##sys#substring obj i j) col)))))) ((char? obj) (if display? -- 1.7.2.5 _______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers