mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-21 10:47:34 -05:00
Signed-off-by: Alexis Saettler <alexis@saettler.org> Co-authored-by: Alexis Saettler <alexis@saettler.org>
45 lines
1.5 KiB
Plaintext
45 lines
1.5 KiB
Plaintext
---
|
|
sidebar_label: textdecodebase64
|
|
description: >-
|
|
The textdecodebase64 function decodes a string that was previously
|
|
Base64-encoded,
|
|
|
|
and then interprets the result as characters in a specified character
|
|
encoding.
|
|
---
|
|
|
|
# `textdecodebase64` Function
|
|
|
|
`textdecodebase64` function decodes a string that was previously Base64-encoded,
|
|
and then interprets the result as characters in a specified character encoding.
|
|
|
|
```hcl
|
|
textdecodebase64(string, encoding_name)
|
|
```
|
|
|
|
OpenTofu uses the "standard" Base64 alphabet as defined in
|
|
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4).
|
|
|
|
The `encoding_name` argument must contain one of the encoding names or aliases
|
|
recorded in
|
|
[the IANA character encoding registry](https://www.iana.org/assignments/character-sets/character-sets.xhtml).
|
|
OpenTofu supports only a subset of the registered encodings, and the encoding
|
|
support may vary between OpenTofu versions.
|
|
|
|
OpenTofu accepts the encoding name `UTF-8`, which will produce the same result
|
|
as [`base64decode`](../../language/functions/base64decode.mdx).
|
|
|
|
## Examples
|
|
|
|
```
|
|
> textdecodebase64("SABlAGwAbABvACAAVwBvAHIAbABkAA==", "UTF-16LE")
|
|
Hello World
|
|
```
|
|
|
|
## Related Functions
|
|
|
|
* [`textencodebase64`](../../language/functions/textencodebase64.mdx) performs the opposite operation,
|
|
applying target encoding and then Base64 to a string.
|
|
* [`base64decode`](../../language/functions/base64decode.mdx) is effectively a shorthand for
|
|
`textdecodebase64` where the character encoding is fixed as `UTF-8`.
|