mes: Add char-downcase, char-upcase.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 11 Nov 2018 09:10:43 +0000 (10:10 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 11 Nov 2018 09:10:43 +0000 (10:10 +0100)
* mes/module/srfi/srfi-14.mes (char-downcase, char-upcase): New
function.

mes/module/srfi/srfi-14.mes

index a0a96b924cb2e3e7d7e7c7620a7e4bc2122a200c..2e925ec58a7563a0d51efe1807f758e6f055892c 100644 (file)
 
 (define (char-set-copy cs)
   (map identity cs))
+
+(define (char-upcase c)
+  (if (char-set-contains? char-set:lower-case c) (integer->char (- (char->integer c)
+                                                                   (- (char->integer #\a)
+                                                                      (char->integer #\A))))
+      c))
+
+(define (char-downcase c)
+  (if (char-set-contains? char-set:upper-case c) (integer->char (+ (char->integer c)
+                                                                   (- (char->integer #\a)
+                                                                      (char->integer #\A))))
+      c))