Loading TOC...

xdmp:url-encode

xdmp:url-encode(
   $plaintext as xs:string,
   [$noSpacePlus as xs:boolean?]
) as xs:string

Summary

Converts plaintext into URL-encoded string. To decode the string, use xdmp:url-decode.

There is also a W3C function that does a slightly different url encoding: fn:encode-for-uri.

Parameters
$plaintext Plaintext to be encoded.
$noSpacePlus True to encode space as "%20" instead of "+".

Example

xdmp:url-encode("Why not?");
=> "Why+not%3f"

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • What are the differences between this function and fn:encode-for-uri?
    • It looks like there are at least two differences: 1. xdmp:url-encode leaves '/' untouched while fn:encode-for-uri as '%2F'. 2. xdmp:url-encode uses lowercase hexadecimal and fn:encode-for-uri uses uppercase - %3d versus %3D