github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/encoding/urlencode.mdx (about) 1 --- 2 layout: docs 3 page_title: urlencode - Functions - Configuration Language 4 description: The urlencode function applies URL encoding to a given string. 5 --- 6 7 # `urlencode` Function 8 9 `urlencode` applies URL encoding to a given string. 10 11 This function identifies characters in the given string that would have a 12 special meaning when included as a query string argument in a URL and 13 escapes them using 14 [RFC 3986 "percent encoding"](https://tools.ietf.org/html/rfc3986#section-2.1). 15 16 The exact set of characters escaped may change over time, but the result 17 is guaranteed to be interpolatable into a query string argument without 18 inadvertently introducing additional delimiters. 19 20 If the given string contains non-ASCII characters, these are first encoded as 21 UTF-8 and then percent encoding is applied separately to each UTF-8 byte. 22 23 ## Examples 24 25 ```shell-session 26 > urlencode("Hello World") 27 Hello%20World 28 > urlencode("☃") 29 %E2%98%83 30 > "http://example.com/search?q=${urlencode("nomad urlencode")}" 31 http://example.com/search?q=nomad%20urlencode 32 ```