Base64 encode data: Difference between revisions
Content added Content deleted
(My solution in Common Lisp) |
|||
Line 485: | Line 485: | ||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
A nice example for the CL eco system using [http://quickdocs.org/cl-base64/ cl-base64] and [https://www.cliki.net/Drakma drakma]. |
|||
<lang lisp> |
|||
(eval-when (:load-toplevel :compile-toplevel :execute) |
<lang lisp>(eval-when (:load-toplevel :compile-toplevel :execute) |
||
(ql:quickload "drakma") |
(ql:quickload "drakma") |
||
(ql:quickload "cl-base64")) |
(ql:quickload "cl-base64")) |
||
Line 501: | Line 502: | ||
(output (loop |
(output (loop |
||
with array = (make-array 0 :element-type 'unsigned-byte |
with array = (make-array 0 :element-type 'unsigned-byte |
||
:adjustable t :fill-pointer 0) |
:adjustable t :fill-pointer 0) |
||
for data-chunk = (read-byte input nil nil) |
for data-chunk = (read-byte input nil nil) |
||
while data-chunk |
while data-chunk |
||
Line 507: | Line 508: | ||
finally (return (usb8-array-to-base64-string array))))) |
finally (return (usb8-array-to-base64-string array))))) |
||
(close input) |
(close input) |
||
output)) |
output))</lang> |
||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre>"AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///...</pre> |
<pre>"AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///...</pre> |