How do I urlencode a url parameter in XSLT?
In php there is a function rawurlencode that does what I want, urlencode according to RFC 3986.
The UrlEncode(String) method can be used to encode the entire URL, including query-string values. If characters such as blanks and punctuation are passed in an HTTP stream without encoding, they might be misinterpreted at the receiving end.
General Answer. The general answer to your question is that it depends. And you get to decide by specifying what your "Content-Type" is in the HTTP headers. A value of "application/x-www-form-urlencoded" means that your POST body will need to be URL encoded just like a GET parameter string.
XPath 2.0 (and hence XSLT 2.0) has the encode-for-uri
function. I'm not aware of any way to do it in plain XPath 1.0/XSLT 1.0 without using extension functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With