FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Unrevised from 9.0 to 10.0.
9.0 version

usb8-array-to-base64-string

Arguments: usb8-array &key (wrap-at-column 52) start end

Takes the (unsigned-byte 8) array specified by the usb8-array, assumes it is a base64 encoding (with the first (index 0 or index start) element the most significant), and converts it to a base64 string. If wrap-at-column is non-nil, its value must be a positive integer and newlines are inserted in the string each time that number of characters is output. If wrap-at-column is nil, no newlines are inserted. start and end specify the portion of the usb8-array to convert. If unspecified, the whole array is converted.

In releases prior to 8.1, there was no start or end wrguments and wrap-at-column was an optional argument rather than a keyword argument. The optional argument calling sequence is still accepted though strongly discouraged. Thus (usb8-array-to-base64-string usb8-array 80) is accepted and equivalent to (usb8-array-to-base64-string usb8-array :wrap-at-column 80). If you use the optional argument calling sequence, you may not also specify values for start or end.

The function base64-string-to-usb8-array converts a base64 string (the output of this function) back to an (unsigned-byte 8) array.

Here are some examples. First we show that the first array element is the most significant (using base64-string-to-integer). Then we give a more complex example.

cl-user(2): (setq ar1 (make-array 2 :element-type '(unsigned-byte 8)
                          :initial-contents '(10 40)))
#(10 40)
cl-user(3): (setq b1 (usb8-array-to-base64-string ar1))
"Cig="
cl-user(4): (base64-string-to-integer b1)
2600  ;;  equals (+ (* 10 (expt 2 8)) 40) equals (+ 2560 40)

cl-user(5): (setq a (string-to-octets
		     (setq s
		       "
(defun deep-thought ()
  (sleep (years2secs 7500000))
  42)
")))
#(10 40 100 101 102 117 110 32 100 101 ...)
cl-user(6): (usb8-array-to-base64-string a)
"CihkZWZ1biBkZWVwLXRob3VnaHQgKCkKICAoc2xlZXAgKHllYXJz
MnNlY3MgNzUwMDAwMCkpCiAgNDIpCgA="
cl-user(7): (base64-string-to-usb8-array *)
#(10 40 100 101 102 117 110 32 100 101 ...)
cl-user(8): (setq a2 *)
#(10 40 100 101 102 117 110 32 100 101 ...)
cl-user(9): (equalp a a2)
t
cl-user(10): (octets-to-string a2)
"
(defun deep-thought ()
  (sleep (years2secs 7500000))
  42)
"
61
61

See Base64 Support in miscellaneous.htm for information on Base64 and Base64 support in Allegro CL.


Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 9.0 page.
Created 2015.5.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Unrevised from 9.0 to 10.0.
9.0 version