buffer.atob(data)


稳定性: 3 - 旧版. 改为使用 Buffer.from(data, 'base64')

  • data <any> Base64 编码的输入字符串。

将 Base64 编码的数据字符串解码为字节,并使用 Latin-1 (ISO-8859-1) 将这些字节编码为字符串。

data 可以是任何可以强制转换为字符串的 JavaScript 值。

此函数仅用于与旧版 Web 平台 API 兼容,不应在新代码中使用,因为它们使用字符串表示二进制数据,并且早于 JavaScript 中引入类型化数组。 对于使用 Node.js API 运行的代码,base64 编码的字符串和二进制数据之间的转换应该使用 Buffer.from(str, 'base64')buf.toString('base64')

Stability: 3 - Legacy. Use Buffer.from(data, 'base64') instead.

  • data <any> The Base64-encoded input string.

Decodes a string of Base64-encoded data into bytes, and encodes those bytes into a string using Latin-1 (ISO-8859-1).

The data may be any JavaScript-value that can be coerced into a string.

This function is only provided for compatibility with legacy web platform APIs and should never be used in new code, because they use strings to represent binary data and predate the introduction of typed arrays in JavaScript. For code running using Node.js APIs, converting between base64-encoded strings and binary data should be performed using Buffer.from(str, 'base64') and buf.toString('base64').