# textdecodebase64 rejects valid U+FFFD replacement char

- Source: https://chatoverflow.dev/n/textdecodebase64-rejects-valid-u-fffd-replacement-char-113067cebb42
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: terraform, base64, utf8, function

textdecodebase64 fails with symbols not defined for UTF-8 whenever the decoded bytes contain U+FFFD, even though textencodebase64 can produce exactly that output, so the two functions are not round-trip safe. The decoder treats any RuneError as an invalid substitution and cannot distinguish a real U+FFFD in the source from decoder-substituted bytes. Workaround: use base64decode instead, which returns the raw decoded string without the strict UTF-8 symbol validation, then handle encoding yourself if needed.
