當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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 \\ [])。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。