diff --git a/collects/net/scribblings/base64.scrbl b/collects/net/scribblings/base64.scrbl index 0d3b6293ed..a3a8920558 100644 --- a/collects/net/scribblings/base64.scrbl +++ b/collects/net/scribblings/base64.scrbl @@ -8,11 +8,12 @@ utilities for Base 64 (MIME-standard) encoding and decoding.} @section[#:tag "base64-procs"]{Functions} -@defproc[(base64-encode [bstr bytes?]) bytes?]{ +@defproc[(base64-encode [bstr bytes?] [newline-bstr bytes? #"\r\n"]) bytes?]{ Consumes a byte string and returns its Base 64 encoding as a new byte string. The returned string is broken into 72-byte lines separated by -CRLF combinations, and always ends with a CRLF combination unless the +@racket[newline-bstr], which defaults to a CRLF combination, and the +result always ends with a @racket[newline-bstr] unless the input is empty.} diff --git a/collects/tests/racket/net.rktl b/collects/tests/racket/net.rktl index 9b86f927f5..33e1c297ea 100644 --- a/collects/tests/racket/net.rktl +++ b/collects/tests/racket/net.rktl @@ -12,4 +12,11 @@ net/qp mzlib/port) +(test #"" base64-encode #"") +(test #"" base64-encode #"" #"<>") +(test #"V2h5IGRvIGF4ZSBtdXJkZXJlcnMgb25seSBhdHRhY2sKV2hlbiB5b3UncmUgcGFydGlhbGx5\r\nIG51ZGUKT3IgeW91J3JlIHRha2luZyBhIGJhdGg=\r\n" + base64-encode #"Why do axe murderers only attack\nWhen you're partially nude\nOr you're taking a bath") +(test #"V2h5IGRvIGF4ZSBtdXJkZXJlcnMgb25seSBhdHRhY2sKV2hlbiB5b3UncmUgcGFydGlhbGx5<>IG51ZGUKT3IgeW91J3JlIHRha2luZyBhIGJhdGg=<>" + base64-encode #"Why do axe murderers only attack\nWhen you're partially nude\nOr you're taking a bath" #"<>") + (report-errs)