base64_encode_fromarray()base64_encode_fromarray()

从字节数组对 base64 字符串进行编码。Encodes a base64 string from a bytes array.

语法Syntax

base64_encode_fromarray(BytesArray)base64_encode_fromarray(BytesArray)

参数Arguments

  • BytesArray:输入要编码为 base64 字符串的字节数组。BytesArray: Input bytes array to be encoded into base64 string.

返回Returns

返回从字节数组进行编码的 base64 字符串。Returns the base64 string encoded from the bytes array.

示例Example

let bytes_array = toscalar(print base64_decode_toarray("S3VzdG8="));
print decoded_base64_string = base64_encode_fromarray(bytes_array)
decoded_base64_stringdecoded_base64_string
S3VzdG8=S3VzdG8=

尝试从无效 UTF-8 编码字符串生成的无效字节数组中对 base64 字符串进行编码将返回 null:Trying to encode a base64 string from an invalid bytes array which 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_stringempty_string