Finn Årup Nielsen
Finn Årup Nielsen

Reputation: 6726

Escape string for conversion to URI in SPARQL

Is there a simple way to escape a string in SPARQL when it is to be converted to a URI?

For instance, a string with "1 < 2" could be converted to "1%20%3C%202".

I suppose a long series of calls to the REPLACE function could do it, following the pattern BIND(REPLACE(?string, '<', '%3C') AS ?escaped)?

Upvotes: 1

Views: 1417

Answers (1)

AndyS
AndyS

Reputation: 16700

There is a function ENCODE_FOR_URI:

ENCODE_FOR_URI("1 < 2") => "1%20%3C%202"

Specification: https://www.w3.org/TR/sparql11-query/#func-encode

Upvotes: 4

Related Questions