Skip to content

Commit d714854

Browse files
committed
Remove conversion to utf-8
1 parent 6388acb commit d714854

File tree

1 file changed

+13
-2
lines changed
  • web-server-lib/web-server/private

1 file changed

+13
-2
lines changed

web-server-lib/web-server/private/util.rkt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@
1111

1212
;; --
1313

14+
(define (byte-upcase b)
15+
(if (<= 97 b 122)
16+
(- b (- 97 65))
17+
b))
1418
(define (bytes-ci=? b0 b1)
15-
(string-ci=? (bytes->string/utf-8 b0)
16-
(bytes->string/utf-8 b1)))
19+
(and (= (bytes-length b0)
20+
(bytes-length b1))
21+
(for/and ([b0 (in-bytes b0)]
22+
[b1 (in-bytes b1)])
23+
(= (byte-upcase b0) (byte-upcase b1)))))
1724
;; Eli: If this ever gets in, it should say that the memory requirements
1825
;; are 4 times the input size, especially since bytes are often used to save
1926
;; space. Also, fails on (bytes-ci=? #"\277" #"\277"), and a trivial fix
@@ -22,6 +29,10 @@
2229
(provide/contract
2330
[bytes-ci=? (bytes? bytes? . -> . boolean?)])
2431

32+
(module+ test
33+
(require rackunit)
34+
(check-true (bytes-ci=? #"FBCR/M\351ditel" #"fbCR/M\351ditel")))
35+
2536
;; --
2637

2738
(define path-piece?

0 commit comments

Comments
 (0)