R6RS string escapes broken on string output
scm_to_stringn failed to do the necessary escape conversion for R6RS hex escapes * libguile/strings.c (unistring_escapes_to_r6rs_escapes): new function (scm_to_stringn): use new function when r6rs hex escapes are enabled * test-suite/tests/reader.test: new test for string display
This commit is contained in:
parent
2ff9bf8522
commit
d31b951951
2 changed files with 102 additions and 13 deletions
|
|
@ -283,8 +283,7 @@
|
|||
(with-input-from-string "\"\\x41;\\x0042;\\x000043;\"" read)))
|
||||
"ABC"))
|
||||
|
||||
(pass-if "write R6RS escapes"
|
||||
|
||||
(pass-if "write R6RS string escapes"
|
||||
(let* ((s1 (apply string
|
||||
(map integer->char '(#x8 ; backspace
|
||||
#x20 ; space
|
||||
|
|
@ -298,6 +297,20 @@
|
|||
(lset= eqv?
|
||||
(string->list s2)
|
||||
(list #\" #\\ #\x #\8 #\; #\space #\0 #\@ #\"))))
|
||||
|
||||
(pass-if "display R6RS string escapes"
|
||||
(string=?
|
||||
(with-read-options '(r6rs-hex-escapes)
|
||||
(lambda ()
|
||||
(let ((pt (open-output-string))
|
||||
(s1 (apply string (map integer->char
|
||||
'(#xFF #x100 #xFFF #x1000 #xFFFF #x10000)))))
|
||||
(set-port-encoding! pt "ASCII")
|
||||
(set-port-conversion-strategy! pt 'escape)
|
||||
(display s1 pt)
|
||||
(get-output-string pt))))
|
||||
"\\xff;\\x100;\\xfff;\\x1000;\\xffff;\\x10000;"))
|
||||
|
||||
(pass-if "one-digit hex escape"
|
||||
(eqv? (with-read-options '(r6rs-hex-escapes)
|
||||
(lambda ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue