mirror of https://github.com/hashicorp/terraform
parent
7a31e56cb7
commit
877399c631
@ -0,0 +1,40 @@
|
||||
---
|
||||
layout: "functions"
|
||||
page_title: "encodetextbase64 - Functions - Configuration Language"
|
||||
sidebar_current: "docs-funcs-encoding-encodetextbase64"
|
||||
description: |-
|
||||
The encodetextbase64 function decodes a string containing a base64 sequence assuming that the target encoding was used.
|
||||
---
|
||||
|
||||
# `decodetextbase64` Function
|
||||
|
||||
-> **Note:** This function is supported only in Terraform v0.14 and later.
|
||||
|
||||
`decodetextbase64` function decodes a string that was previously Base64-encoded,
|
||||
and then interprets the result as characters in a specified character encoding.
|
||||
|
||||
Terraform 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).
|
||||
Terraform supports only a subset of the registered encodings, and the encoding
|
||||
support may vary between Terraform versions.
|
||||
|
||||
Terraform accepts the encoding name `UTF-8`, which will produce the same result
|
||||
as [`base64decode`](./base64decode.html).
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
> decodetextbase64("SABlAGwAbABvACAAVwBvAHIAbABkAA==", "UTF-16LE")
|
||||
Hello World
|
||||
```
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`encodetextbase64`](./encodetextbase64.html) performs the opposite operation,
|
||||
applying target encoding and then Base64 to a string.
|
||||
* [`base64decode`](./base64decode.html) is effectively a shorthand for
|
||||
`decodetextbase64` where the character encoding is fixed as `UTF-8`.
|
||||
@ -0,0 +1,50 @@
|
||||
---
|
||||
layout: "functions"
|
||||
page_title: "encodetextbase64 - Functions - Configuration Language"
|
||||
sidebar_current: "docs-funcs-encoding-encodetextbase64"
|
||||
description: |-
|
||||
The encodetextbase64 function applies Base64 encoding to a string that was encoded to target encoding before.
|
||||
---
|
||||
|
||||
# `encodetextbase64` Function
|
||||
|
||||
-> **Note:** This function is supported only in Terraform v0.14 and later.
|
||||
|
||||
`encodetextbase64` encodes the unicode characters in a given string using a
|
||||
specified character encoding, returning the result base64 encoded because
|
||||
Terraform language strings are always sequences of unicode characters.
|
||||
|
||||
```hcl
|
||||
substr(string, encoding_name)
|
||||
```
|
||||
|
||||
Terraform 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).
|
||||
Terraform supports only a subset of the registered encodings, and the encoding
|
||||
support may vary between Terraform versions. In particular Terraform supports
|
||||
`UTF-16LE`, which is the native character encoding for the Windows API and
|
||||
therefore sometimes expected by Windows-originated software such as PowerShell.
|
||||
|
||||
Terraform also accepts the encoding name `UTF-8`, which will produce the same
|
||||
result as [`base64encode`](./base64encode.html).
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
> encodetextbase64("Hello World", "UTF-16LE")
|
||||
SABlAGwAbABvACAAVwBvAHIAbABkAA==
|
||||
```
|
||||
|
||||
## Related Functions
|
||||
|
||||
* [`decodetextbase64`](./decodetextbase64.html) performs the opposite operation,
|
||||
decoding Base64 data and interpreting it as a particular character encoding.
|
||||
* [`base64encode`](./base64encode.html) applies Base64 encoding of the UTF-8
|
||||
encoding of a string.
|
||||
* [`filebase64`](./filebase64.html) reads a file from the local filesystem
|
||||
and returns its raw bytes with Base64 encoding, without creating an
|
||||
intermediate Unicode string.
|
||||
Loading…
Reference in new issue