Handling Special Characters in SPARQL-Filter Expressions
I am accessing SPARQL-Endpoint dbpedia [1] to get the URI for a given city. To do this, I use the following query:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/ontology/>
select distinct * where
{?uri rdfs:label ?label.
FILTER (REGEX(STR(?label), "^Köln$", "i")).
?uri a dbpedia:PopulatedPlace.
}
If I ask for a city without a German umlaut, everything works fine, but if there is an umlaut, I get nothing. When executing this request with code, I even get a 406 error (Invalid)
Any idea how to deal with umlauts in a SPARQL query against dbpedia?
Thanks in advance,
Frank
+3
source to share
1 answer
There seems to be a mistake in handling your character, maybe in transport or otherwise. It works when you just write it in unicode hex for ö , for example:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/ontology/>
select distinct * where
{?uri rdfs:label ?label.
FILTER (REGEX(STR(?label), "^K\u00F6ln$")).
?uri a dbpedia:PopulatedPlace.
}
Edit: I can see now that this doesn't work with the 'i' flag. The documentation assumes the "u" flag is applicable here.
+3
source to share