diff --git a/lib/scheme/char/full.scm b/lib/scheme/char/full.scm index 31c3b32a..4f994ea6 100644 --- a/lib/scheme/char/full.scm +++ b/lib/scheme/char/full.scm @@ -77,7 +77,7 @@ (proc out) (get-output-string out))) -(define (string-downcase str) +(define (string-down-or-fold-case str fold?) (call-with-output-string (lambda (out) (let ((in (open-input-string str))) @@ -86,7 +86,7 @@ (cond ((not (eof-object? ch)) (display - (if (eqv? ch #\x03A3) + (if (and (not fold?) (eqv? ch #\x03A3)) (let ((ch2 (peek-char in))) (if (or (eof-object? ch2) (not (char-set-contains? char-set:letter ch2))) @@ -96,7 +96,8 @@ out) (lp))))))))) -(define string-foldcase string-downcase) +(define (string-downcase str) (string-down-or-fold-case str #f)) +(define (string-foldcase str) (string-down-or-fold-case str #t)) (define (string-upcase str) (call-with-output-string diff --git a/tests/r7rs-tests.scm b/tests/r7rs-tests.scm index d3150887..2057a173 100644 --- a/tests/r7rs-tests.scm +++ b/tests/r7rs-tests.scm @@ -1194,7 +1194,7 @@ (test "γλώσσα" (string-foldcase "ΓΛΏΣΣΑ")) (test "ΜΈΛΟΣ" (string-upcase "μέλος")) (test "μέλος" (string-downcase "ΜΈΛΟΣ")) -(test "μέλος" (string-foldcase "ΜΈΛΟΣ")) +(test "μέλοσ" (string-foldcase "ΜΈΛΟΣ")) (test "μέλος ενός" (string-downcase "ΜΈΛΟΣ ΕΝΌΣ")) (test "" (substring "" 0 0))