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