Encodes reserved characters in a string that is intended to be used in the path segment of a URI.
$uri-part is the empty sequence, the function returns the zero-length
This function applies the URI escaping rules defined in section 2 of to the
xs:string supplied as
effect of the function is to escape reserved characters. Each such character in the
string is replaced with its percent-encoded form as described in .
Since recommends that, for consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings, this function must always generate hexadecimal values using the upper-case letters A-F.
concat("http://www.example.com/", encode-for-uri("100% organic")) returns
All characters are escaped except those identified as "unreserved" by , that is the upper- and lower-case letters A-Z, the digits 0-9, HYPHEN-MINUS ("-"), LOW LINE ("_"), FULL STOP ".", and TILDE "~".
This function escapes URI delimiters and therefore cannot be used indiscriminately to encode "invalid" characters in a path segment.
This function is invertible but not idempotent. This is because a string containing a
percent character will be modified by applying the function: for example