Skip to content

UrlEncode

Maarten Hilferink edited this page Apr 8, 2026 · 1 revision

String functions UrlEncode

The UrlEncode function encodes strings for safe use in URLs by escaping special characters.

syntax

UrlEncode(strings: E->String) -> E->String

definition

Converts strings to URL-safe format by replacing special characters with percent-encoded sequences (e.g., space becomes %20, & becomes %26).

Characters that are encoded include:

  • Spaces and control characters
  • Reserved URL characters: !, #, $, &, ', (, ), *, +, ,, /, :, ;, =, ?, @, [, ]
  • Non-ASCII characters

Characters that remain unencoded:

  • Letters (A-Z, a-z)
  • Digits (0-9)
  • Unreserved characters: -, _, ., ~

arguments

argument description type
strings Input strings to encode E->String

performance

Time complexity: O(n × L) where n is the number of strings and L is the average string length.

Encoded strings are typically longer than input strings (each special character becomes 3 characters).

example

unit<uint32> QueryParams: nrofrows = 3;
attribute<String> values (QueryParams) := union_data(QueryParams,
    'hello world',
    'price=100&tax=20',
    'name=Müller'
);

attribute<String> encoded (QueryParams) := UrlEncode(values);
// encoded = {'hello%20world', 'price%3D100%26tax%3D20', 'name%3DM%C3%BCller'}

// Building URL query string
parameter<String> base_url := 'https://api.example.com/search?q=';
attribute<String> full_url (QueryParams) := base_url + encoded;

see also

since version

7.0

Clone this wiki locally