base64_encode_fromarray()
Encodes a base64 string from a bytes array.
Syntax
base64_encode_fromarray(BytesArray)
Arguments
- BytesArray: Input bytes array to be encoded into base64 string.
Returns
Returns the base64 string encoded from the bytes array.
- For decoding base64 strings to a UTF-8 string see base64_decode_tostring()
- For encoding strings to base64 string see base64_encode_tostring()
- This function is the inverse of base64_decode_toarray()
Example
let bytes_array = toscalar(print base64_decode_toarray("S3VzdG8="));
print decoded_base64_string = base64_encode_fromarray(bytes_array)
| decoded_base64_string |
|---|
| S3VzdG8= |
Trying to encode a base64 string from an invalid bytes array that was generated from invalid UTF-8 encoded string will return null:
let empty_bytes_array = toscalar(print base64_decode_toarray("U3RyaW5n0KHR0tGA0L7Rh9C60LA"));
print empty_string = base64_encode_fromarray(empty_bytes_array)
| empty_string |
|---|
Feedback
Submit and view feedback for