Merge commit 'factor/master'
commit
8c6da81121
|
@ -7,7 +7,13 @@ HELP: >base64
|
|||
{ $examples
|
||||
{ $example "USING: prettyprint base64 strings ;" "\"The monorail is a free service.\" >base64 >string ." "\"VGhlIG1vbm9yYWlsIGlzIGEgZnJlZSBzZXJ2aWNlLg==\"" }
|
||||
}
|
||||
{ $see-also base64> } ;
|
||||
{ $see-also base64> >base64-lines } ;
|
||||
|
||||
HELP: >base64-lines
|
||||
{ $values { "seq" sequence } { "base64" "a string of base64 characters" } }
|
||||
{ $description "Converts a sequence to its base64 representation by taking six bits at a time as an index into a lookup table containing alphanumerics, '+', and '/'. The result is padded with '=' if the input was not a multiple of six bits. A crlf is inserted for every 76 characters of output." }
|
||||
{ $see-also base64> >base64-lines } ;
|
||||
|
||||
|
||||
HELP: base64>
|
||||
{ $values { "base64" "a string of base64 characters" } { "seq" sequence } }
|
||||
|
@ -16,13 +22,26 @@ HELP: base64>
|
|||
{ $example "USING: prettyprint base64 strings ;" "\"VGhlIG1vbm9yYWlsIGlzIGEgZnJlZSBzZXJ2aWNlLg==\" base64> >string ." "\"The monorail is a free service.\"" }
|
||||
}
|
||||
{ $notes "This word will throw if the input string contains characters other than those allowed in base64 encodings." }
|
||||
{ $see-also >base64 } ;
|
||||
{ $see-also >base64 >base64-lines } ;
|
||||
|
||||
HELP: encode-base64
|
||||
{ $description "Reads the standard input and writes it to standard output encoded in base64." } ;
|
||||
|
||||
HELP: decode-base64
|
||||
{ $description "Reads the standard input and decodes it, writing to standard output." } ;
|
||||
|
||||
HELP: encode-base64-lines
|
||||
{ $description "Reads the standard input and writes it to standard output encoded in base64 with a crlf every 76 characters." } ;
|
||||
|
||||
ARTICLE: "base64" "Base 64 conversions"
|
||||
"The " { $vocab-link "base64" } " vocabulary implements conversions of sequences to printable characters in base 64. These plain-text representations of binary data may be passed around and converted back to binary data later." $nl
|
||||
"Converting to base 64:"
|
||||
"Converting to and from base64 as strings:"
|
||||
{ $subsection >base64 }
|
||||
"Converting back to binary:"
|
||||
{ $subsection base64> } ;
|
||||
{ $subsection >base64-lines }
|
||||
{ $subsection base64> }
|
||||
"Using base64 from streams:"
|
||||
{ $subsection encode-base64 }
|
||||
{ $subsection encode-base64-lines }
|
||||
{ $subsection decode-base64 } ;
|
||||
|
||||
ABOUT: "base64"
|
||||
|
|
|
@ -74,11 +74,11 @@ PRIVATE>
|
|||
[ malformed-base64 ]
|
||||
} case ;
|
||||
|
||||
: >base64 ( str -- base64 )
|
||||
: >base64 ( seq -- base64 )
|
||||
binary [ [ encode-base64 ] with-string-reader ] with-byte-writer ;
|
||||
|
||||
: base64> ( base64 -- str )
|
||||
: base64> ( base64 -- seq )
|
||||
[ binary [ decode-base64 ] with-byte-reader ] with-string-writer ;
|
||||
|
||||
: >base64-lines ( str -- base64 )
|
||||
binary [ [ encode-base64-lines ] with-string-reader ] with-byte-writer ;
|
||||
: >base64-lines ( seq -- base64 )
|
||||
binary [ [ encode-base64-lines ] with-string-reader ] with-byte-writer ;
|
||||
|
|
Loading…
Reference in New Issue