I'm trying to generate a url encoded string using a sparql query. My goal is to have a link into the stardog webui, but this could be for any service that takes a URI as an argument. Here is an example query
select *
where {
?dataset a dcat:Dataset ;
bind(concat("http://localhost:5820/mydb#!/browse/resource/", encode_for_uri(str(?dataset))) as ?kg)
}
Per the W3C REC [1], the ENCODE_FOR_URI returns a simple literal with the lexical form obtained from the lexical form of its input after translating reserved characters according to the fn:encode-for-uri function
So normally from your sample, you should get what you were expecting, http%3A%2F%2Ffoo.bar.com%2FmyIRI