跳至主要内容

textdecodebase64 函数

textdecodebase64 函数解码之前使用 Base64 编码的字符串,然后将结果解释为指定字符编码中的字符。

代码块
textdecodebase64(string, encoding_name)

OpenTofu 使用 RFC 4648 第 4 节 中定义的“标准” Base64 字母表。

encoding_name 参数必须包含 IANA 字符编码注册表 中记录的编码名称或别名之一。OpenTofu 仅支持注册编码的子集,编码支持可能在 OpenTofu 版本之间有所不同。

OpenTofu 接受编码名称 UTF-8,这将产生与 base64decode 相同的结果。

示例

代码块
> textdecodebase64("SABlAGwAbABvACAAVwBvAHIAbABkAA==", "UTF-16LE")
Hello World
  • textencodebase64 执行相反的操作,将目标编码应用于字符串,然后进行 Base64 编码。
  • base64decode 实际上是 textdecodebase64 的简写,其中字符编码固定为 UTF-8