From 54e92078dabbe10b9a935fb42a4fcf8c7d076e63 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 19 Feb 2004 20:51:22 +0000 Subject: [PATCH] . original commit: f78cb80a55b96173e8aca8ce96186d069b88f5cb --- collects/net/base64-unit.ss | 36 ++++++++++++++++++------------------ collects/net/cookie-unit.ss | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/collects/net/base64-unit.ss b/collects/net/base64-unit.ss index 3dc30ea..1efcffb 100644 --- a/collects/net/base64-unit.ss +++ b/collects/net/base64-unit.ss @@ -66,7 +66,7 @@ ;; Process input 3 characters at a time, because 18 bits ;; is divisible by both 6 and 8, and 72 (the line length) ;; is divisible by 3. - (let ([three (make-string 3)] + (let ([three (make-bytes 3)] [outc (lambda (n) (display (vector-ref digit-base64 n) out))] [done (lambda (fill) @@ -82,16 +82,16 @@ (display linesep out) (loop 0)) ;; Next group of 3 - (let ([n (read-string-avail! three in)]) + (let ([n (read-bytes-avail! three in)]) (cond [(eof-object? n) (unless (= pos 0) (done 0))] [(= n 3) ;; Easy case: - (let ([a (char->integer (string-ref three 0))] - [b (char->integer (string-ref three 1))] - [c (char->integer (string-ref three 2))]) + (let ([a (bytes-ref three 0)] + [b (bytes-ref three 1)] + [c (bytes-ref three 2)]) (outc (arithmetic-shift a -2)) (outc (+ (bitwise-and #x3f (arithmetic-shift a 4)) (arithmetic-shift b -4))) @@ -101,14 +101,14 @@ (loop (+ pos 4)))] [else ;; Hard case: n is 1 or 2 - (let ([a (char->integer (string-ref three 0))]) + (let ([a (bytes-ref three 0)]) (outc (arithmetic-shift a -2)) (let* ([next (if (= n 2) - (string-ref three 1) - (read-char in))] - [b (if (char? next) - (char->integer next) - 0)]) + (bytes-ref three 1) + (read-byte in))] + [b (if (eof-object? next) + 0 + next)]) (outc (+ (bitwise-and #x3f (arithmetic-shift a 4)) (arithmetic-shift b -4))) (if (eof-object? next) @@ -128,13 +128,13 @@ (loop (+ pos 4))))))))])))))])) (define (base64-decode src) - (let ([s (open-output-string)]) - (base64-decode-stream (open-input-string src) s) - (get-output-string s))) + (let ([s (open-output-bytes)]) + (base64-decode-stream (open-input-bytes src) s) + (get-output-bytes s))) (define (base64-encode src) - (let ([s (open-output-string)]) - (base64-encode-stream (open-input-string src) s - (string #\return #\newline)) - (get-output-string s)))))) + (let ([s (open-output-bytes)]) + (base64-encode-stream (open-input-bytes src) s + (bytes 13 10)) + (get-output-bytes s)))))) diff --git a/collects/net/cookie-unit.ss b/collects/net/cookie-unit.ss index ca88967..bee49f5 100644 --- a/collects/net/cookie-unit.ss +++ b/collects/net/cookie-unit.ss @@ -239,7 +239,7 @@ (char-set-difference char-set:punctuation (string->char-set "_")) char-set:whitespace)) (define char-set:control (char-set-union char-set:iso-control - (char-set (latin-1-integer->char 127))));; DEL + (char-set (integer->char 127))));; DEL (define char-set:token (char-set-difference char-set:ascii char-set:tspecials char-set:control)) ;;!