((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/base64" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "eggs") (toc)) (section 2 "Base64" (p "Encoding and decoding of base64 strings, as per " (link "http://tools.ietf.org/html/rfc4648" "RFC4648") ".") (p "This means output strings use the character set " (tt "[A-Za-z0-9/+]") " for encoding and the character " (tt "=") " for padding strings to multiples of 4 characters.")) (section 2 "Documentation" (def (sig (procedure "(base64-encode IN [OUT])" (id base64-encode))) (p "Encodes " (tt "IN") " (a string or port) to base64 text on optional output port " (tt "OUT") ", and returns " (tt "OUT") ".") (p "If the output port is omitted, the encoded output is written to a fresh string and returned.")) (def (sig (procedure "(base64-decode IN [OUT])" (id base64-decode))) (p "Decodes base64 text from " (tt "IN") " (a string or port) to optional output port " (tt "OUT") ", and returns " (tt "OUT") ".  Invalid input data is silently skipped.") (p "If the output port is omitted, the decoded output is written to a fresh string and returned.")) (def (sig (parameter "(base64-line-breaks BOOLEAN) [default: #f]" (id base64-line-breaks))) (p "If " (tt "#t") ", the encoder inserts a CRLF into the output string every 76 output characters (57 input characters).  A CRLF will also be appended to the final line, only if it was a partial one (between 1 and 75 output characters).  In a UTF8 environment, character means \"byte\"."))) (section 2 "Examples" (pre "(require-extension base64)\n(define s \"thequickbrownfoxjumpsoverthelazydog\")\n(base64-encode s)\n   ; => \"dGhlcXVpY2ticm93bmZveGp1bXBzb3ZlcnRoZWxhenlkb2c=\"\n(base64-decode (base64-encode s))\n   ; => \"thequickbrownfoxjumpsoverthelazydog\"\n(get-output-string (base64-encode (open-input-string s)\n                                  (open-output-string)))\n   ; => \"dGhlcXVpY2ticm93bmZveGp1bXBzb3ZlcnRoZWxhenlkb2c=\"\n(base64-encode s (current-output-port))\ndGhlcXVpY2ticm93bmZveGp1bXBzb3ZlcnRoZWxhenlkb2c=        ; stdout") (p "A script that encodes a file given on the command-line in the style of " (tt "uuencode -m") ". It reads the entire file into memory:") (pre "#!/usr/local/bin/csi -script\n(use base64)\n(base64-line-breaks #t)\n\n(display\n (base64-encode\n  (call-with-input-file (car (command-line-arguments))\n    (lambda (p) (read-string #f p)))))") (p "Instead, you can use a constant amount of memory by using port I/O:") (pre "#!/usr/local/bin/csi -script\n(use base64)                           ;; uuencode.scm\n(base64-line-breaks #t)\n(base64-encode (current-input-port)\n               (current-output-port)) ") (pre "#!/usr/local/bin/csi -script\n(use base64)                           ;; uudecode.scm\n(base64-decode (current-input-port)\n               (current-output-port))") (pre "$ md5sum chicken-4.0.0.tar.gz\n658deaae356f3360e48d6d1628fc062e  chicken-4.0.0.tar.gz\n$ csi4 -script uuencode.scm < chicken-4.0.0.tar.gz | csi4 -script uudecode.scm | md5sum\n658deaae356f3360e48d6d1628fc062e  -")) (section 2 "About this egg" (section 3 "Author" (ul (li "Bigloo code by James Bailey") (li "Ported to CHICKEN by felix") (li "3.0 implementation by Jim Ursetto"))) (section 3 "Version history" (dl (dt "3.2") (dd "Encoding and decoding support port I/O") (dt "3.1") (dd "Add optional decoder linebreaks") (dt "3.0") (dd "API change, reimplement in Scheme") (dt "2.2") (dd "Fix encoding problem with chars > 127 [zb]") (dt "2.1") (dd "Ported to hygienic Chicken " (int-link "[/users/peter-bex" "Peter Bex") "]") (dt "2.0") (dd "Reimplemented in C for large speedup. [zbigniew]") (dt "1.3") (dd "Replaced implementation with a much faster version by James Bailey") (dt "1.2") (dd "Removed read syntax") (dt "1.1") (dd "Decoding accepts whitespace now.") (dt "1.0") (dd "Initial release."))) (section 3 "License" (pre "Copyright (c) 2004 James Bailey.\nCopyright (c) 2009 Jim Ursetto.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE."))))