mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-13 07:57:35 +02:00
Adding string-downcase-ascii util to (chibi string).
This commit is contained in:
parent
eec5aaa0b4
commit
56b3116e20
3 changed files with 16 additions and 12 deletions
|
@ -62,7 +62,7 @@
|
||||||
(let ((i (string-scan-colon-or-maybe-equal line)))
|
(let ((i (string-scan-colon-or-maybe-equal line)))
|
||||||
(and i
|
(and i
|
||||||
(let ((j (string-skip-white-space line (+ i 1))))
|
(let ((j (string-skip-white-space line (+ i 1))))
|
||||||
(list (string->symbol (string-downcase (substring line 0 i)))
|
(list (string->symbol (string-downcase-ascii (substring line 0 i)))
|
||||||
(substring line j (string-length line)))))))
|
(substring line j (string-length line)))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -72,14 +72,6 @@
|
||||||
(define (ces-convert str . x)
|
(define (ces-convert str . x)
|
||||||
str)
|
str)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; inlined ascii-only srfi-13 string-downcase
|
|
||||||
|
|
||||||
(define (string-downcase s)
|
|
||||||
(call-with-output-string
|
|
||||||
(lambda (out)
|
|
||||||
(string-for-each (lambda (ch) (write-char (char-downcase ch) out)) s))))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;> \subsubsection{RFC2822 Headers}
|
;;> \subsubsection{RFC2822 Headers}
|
||||||
|
|
||||||
|
@ -162,13 +154,14 @@
|
||||||
(define (mime-split-name+value s)
|
(define (mime-split-name+value s)
|
||||||
(let ((i (string-find s #\=)))
|
(let ((i (string-find s #\=)))
|
||||||
(if i
|
(if i
|
||||||
(cons (string->symbol (string-downcase (string-trim (substring s 0 i))))
|
(cons (string->symbol
|
||||||
|
(string-downcase-ascii (string-trim (substring s 0 i))))
|
||||||
(if (= i (string-length s))
|
(if (= i (string-length s))
|
||||||
""
|
""
|
||||||
(if (eqv? #\" (string-ref s (+ i 1)))
|
(if (eqv? #\" (string-ref s (+ i 1)))
|
||||||
(substring s (+ i 2) (- (string-length s) 1))
|
(substring s (+ i 2) (- (string-length s) 1))
|
||||||
(substring s (+ i 1) (string-length s)))))
|
(substring s (+ i 1) (string-length s)))))
|
||||||
(cons (string->symbol (string-downcase (string-trim s))) ""))))
|
(cons (string->symbol (string-downcase-ascii (string-trim s))) ""))))
|
||||||
|
|
||||||
;;> \subsubsubsection{\scheme{(mime-parse-content-type str)}}
|
;;> \subsubsubsection{\scheme{(mime-parse-content-type str)}}
|
||||||
;;> Parses \var{str} as a Content-Type style-value returning the list
|
;;> Parses \var{str} as a Content-Type style-value returning the list
|
||||||
|
|
|
@ -179,3 +179,13 @@
|
||||||
|
|
||||||
(define (make-string-searcher needle)
|
(define (make-string-searcher needle)
|
||||||
(lambda (haystack) (string-contains haystack needle)))
|
(lambda (haystack) (string-contains haystack needle)))
|
||||||
|
|
||||||
|
(define (string-downcase-ascii s)
|
||||||
|
(call-with-output-string
|
||||||
|
(lambda (out)
|
||||||
|
(string-for-each (lambda (ch) (write-char (char-downcase ch) out)) s))))
|
||||||
|
|
||||||
|
(define (string-upcase-ascii s)
|
||||||
|
(call-with-output-string
|
||||||
|
(lambda (out)
|
||||||
|
(string-for-each (lambda (ch) (write-char (char-downcase ch) out)) s))))
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
string-prefix? string-suffix?
|
string-prefix? string-suffix?
|
||||||
string-find string-find-right string-skip string-skip-right
|
string-find string-find-right string-skip string-skip-right
|
||||||
string-fold string-fold-right string-map string-for-each
|
string-fold string-fold-right string-map string-for-each
|
||||||
string-contains make-string-searcher)
|
string-contains make-string-searcher
|
||||||
|
string-downcase-ascii string-upcase-ascii)
|
||||||
(import (chibi) (chibi ast) (chibi char-set base))
|
(import (chibi) (chibi ast) (chibi char-set base))
|
||||||
(include "string.scm"))
|
(include "string.scm"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue