encode | R Documentation |
Encode and decode using base64
encode(what, eng = engine())
decode(what, eng = engine())
decode_as_string(what, newline = "\n", eng = engine())
encode_file(path, eng = engine())
decode_file(path, eng = engine())
what |
a character, raw, or blob vector |
eng |
a base64 engine. See |
newline |
a character sequence to split in the input base64 encoded string on before decoding. |
path |
a path to a base64 encoded file. |
encode()
takes a character vector, list of raw vectors (or blob class), or a raw vector and encodes them into base64 strings.
encode_file()
takes a path to a file and encodes it as a base64 string.
decode()
will decode either a base64 encoded character scalar, a raw vector, or a list of raw vectors (see blob package).
decode_file()
will decode a base64 encoded file into a raw vector.
decode_as_string()
is designed to decode a base64 encoded string to a utf-8 string. By default, it will decode a chunked base64 encoded strings using \n
as the separator. Use the newline
argument to determine how to split the input string prior to decoding.
Both encode()
and decode()
are vectorized. They will return a character
and blob vector the same length as what
, respectively.
decode_as_string()
returns a character scalar.
# encode hello world
encoded <- encode("Hello world")
encoded
# decode to a blob
decoded <- decode(encoded)
decoded
# convert back to a character
rawToChar(decoded[[1]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.