Javascript atob、btoa 为什么要这么命名


atob() 和 btoa() 函数用于 base64 编码与解码,但是命名的简单导致容易记错。

In these APIs, for mnemonic purposes, the "b" can be considered to
stand for "binary", and the "a" for "ASCII". In practice, though, for
primarily historical reasons, both the input and output of these
functions are Unicode strings.
via w3:


  • a:Ascii,即 Base64 编码的展现形式
  • b:Binary,除 Base64 编码以外的形式

“a”指的是 base64,“b”不是指base64

  • atob:Base64 decode
  • btoa:Base64 encode


Tags: base64