mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-21 10:47:34 -05:00
Co-authored-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Co-authored-by: Roman Grinovski <roman.grinovski@gmail.com>
32 lines
978 B
Plaintext
32 lines
978 B
Plaintext
---
|
|
sidebar_label: urlencode
|
|
description: The urlencode function applies URL encoding to a given string.
|
|
---
|
|
|
|
# `urlencode` Function
|
|
|
|
`urlencode` applies URL encoding to a given string.
|
|
|
|
This function identifies characters in the given string that would have a
|
|
special meaning when included as a query string argument in a URL and
|
|
escapes them using
|
|
[RFC 3986 "percent encoding"](https://tools.ietf.org/html/rfc3986#section-2.1).
|
|
|
|
The exact set of characters escaped may change over time, but the result
|
|
is guaranteed to be interpolatable into a query string argument without
|
|
inadvertently introducing additional delimiters.
|
|
|
|
If the given string contains non-ASCII characters, these are first encoded as
|
|
UTF-8 and then percent encoding is applied separately to each UTF-8 byte.
|
|
|
|
## Examples
|
|
|
|
```
|
|
> urlencode("Hello World!")
|
|
Hello+World%21
|
|
> urlencode("☃")
|
|
%E2%98%83
|
|
> "http://example.com/search?q=${urlencode("tofu urlencode")}"
|
|
http://example.com/search?q=tofu+urlencode
|
|
```
|