An atom name and its base64 encoding are related. If the left argument is an atom then it is encoded and the encoded atom is unified with the second argument.
If the left argument is a variable then the predicate tries to create a normal atom from the base64 encoded right argument and unify it with the left argument.
Base-64 encoding, which is defined in Internet RFC 2047, converts a general byte array to a printable byte array. RFC document 2047 can be retrieved from www.rfc-editor.org/rfc.html. A 65-character subset of US-ASCII is used, enabling 6 bits to be represented per printable character. The extra 65th character, "=", is used to signify a special processing function.
To base-64 encode a byte array:
see also: atom_codes/2 atom_compress/2 atom_concat/3 atom_encrypt/3 atom_final_md5/1 atom_integers/2 atom_length/2 atom_reset_md5/0 atom_update_md5/1 base64_decode_file/2 base64_encode_file/2 char_code/2 number_chars/2 number_codes/2 number_integers/2 sub_atom/5
| Example | |
| atom_base64('peter', L). | succeeds, L = 'cGV0ZXI=' |
| atom_base64(N, 'cGV0ZXI='). | succeeds, N = 'peter' |
| atom_base64('peterj', 'cGV0ZXI='). | fails |
| Exceptions | |
| Atom is neither a variable nor an atom | a type_error(atom, Atom) exception is thrown |
| Atom is a variable and Atom64 is a variable is a variable | an instantiation_error exception is thrown |
| Atom64 is not a correct base64 encoded string | an evaluation_error(decode_base64, Atom64) exception is thrown |