Index: guile-core/libguile/print.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/print.c,v retrieving revision 1.155 diff -u -r1.155 print.c --- guile-core/libguile/print.c 11 Oct 2003 00:57:25 -0000 1.155 +++ guile-core/libguile/print.c 18 Nov 2003 19:57:56 -0000 @@ -538,16 +538,24 @@ scm_putc ('"', port); for (i = 0; i < SCM_STRING_LENGTH (exp); ++i) - switch (SCM_STRING_CHARS (exp)[i]) - { - case '"': - case '\\': - scm_putc ('\\', port); - default: - scm_putc (SCM_STRING_CHARS (exp)[i], port); - } + { + unsigned char ch = SCM_STRING_CHARS (exp)[i]; + if ((ch < 32 && ch != '\n') || (127 <= ch && ch < 148)) + { + static char const hex[]="0123456789abcdef"; + scm_putc ('\\', port); + scm_putc ('x', port); + scm_putc (hex [ch / 16], port); + scm_putc (hex [ch % 16], port); + } + else + { + if (ch == '"' || ch == '\\') + scm_putc ('\\', port); + scm_putc (ch, port); + } + } scm_putc ('"', port); - break; } else scm_lfwrite (SCM_STRING_CHARS (exp), SCM_STRING_LENGTH (exp), port);