base64.pl -- Base64 encoding and decoding
Prolog-based base64 encoding using DCG rules. Encoding according to rfc2045. For example:
1 ?- base64('Hello World', X). X = 'SGVsbG8gV29ybGQ='. 2 ?- base64(H, 'SGVsbG8gV29ybGQ='). H = 'Hello World'.
The Base64URL encoding provides a URL and file name friendly alternative to base64. Base64URL encoded strings do not contain white space.
- base64_encoded(+Plain, -Encoded, +Options) is det
- base64_encoded(-Plain, +Encoded, +Options) is det
- General the base64 encoding and decoding. This predicate subsumes
base64/2 and base64url/2, providing control over padding, the
characters used for encoding and the output type. Options:
- charset(+Charset)
- Define the encoding character set to use. The (default)
classic
uses the classical rfc2045 characters. The valueurl
uses URL and file name friendly characters. See base64url/2. - padding(+Boolean)
- If
true
(default), the output is padded with=
characters. - as(+Type)
- Defines the type of the output. One of
string
(default) oratom
. - encoding(+Encoding)
- Encoding to use for translation between (Unicode) text and
bytes (Base64 is an encoding for bytes). Default is
utf8
.
- base64(+Plain, -Encoded) is det
- base64(-Plain, +Encoded) is det
- Equivalent to base64_encoded/3 using the options
as(atom)
andencoding(iso_latin_1)
. - base64url(+Plain, -Encoded) is det
- base64url(-Plain, +Encoded) is det
- Translates between plaintext and base64url encoded atom or
string. Base64URL encoded values can safely be used as URLs and
file names. The use "-" instead of "+", "_" instead of "/" and
do not use padding. This implies that the encoded value cannot
be embedded inside a longer string.
Equivalent to base64_encoded/3 using the options
as(atom)
,encoding(utf8)
andcharset(url)
. - base64_encoded(+PlainText, +Options)// is det
- base64_encoded(-PlainText, +Options)// is det
- base64(+PlainText)// is det
- base64(-PlainText)// is det
- Encode/decode list of character codes using base64. See also base64/2.
- base64url(+PlainText)// is det
- base64url(-PlainText)// is det
- Encode/decode list of character codes using Base64URL. See also base64url/2.