当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Elixir Base.decode64!用法及代码示例


Elixir语言中 Base.decode64! 相关用法介绍如下。

用法:

decode64!(string, opts \\ [])
@spec decode64!(binary(), ignore: :whitespace, padding: boolean()) :: binary()

将 base 64 编码字符串解码为二进制字符串。

接受 ignore: :whitespace 选项,该选项将忽略输入字符串中的所有空白字符。

接受 padding: false 选项,该选项将忽略输入字符串中的填充。

如果填充不正确或字符串中存在非字母字符,则会引发 ArgumentError 异常。

例子

iex> Base.decode64!("Zm9vYmFy")
"foobar"

iex> Base.decode64!("Zm9vYmFy\n", ignore: :whitespace)
"foobar"

iex> Base.decode64!("Zm9vYg==")
"foob"

iex> Base.decode64!("Zm9vYg", padding: false)
"foob"

相关用法


注:本文由纯净天空筛选整理自elixir-lang.org大神的英文原创作品 Base.decode64!(string, opts \\ [])。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。