Handling commas when using a namespace PREFIX in a Sparql WHERE clause

This answer is based in the W3C recommendation for Turtle:

Some special characters are not allowed in the local part of prefixed IRIs. According to the section about IRIs

Prefixed names are a superset of XML QNames. They differ in that the local part of prefixed names may include:

  1. leading digits, e.g. leg:3032571 or isbn13:9780136019701
  2. non leading colons, e.g. og:video:height
  3. reserved character escape sequences, e.g. wgs:lat\-long

In addition, the section about escape sequences gives us more insights:

%-encoded sequences are in the character range for IRIs and are explicitly allowed in local names. These appear as a '%' followed by two hex characters and represent that same sequence of three characters. These sequences are not decoded during processing. A term written as http://a.example/%66oo-bar in Turtle designates the IRI http://a.example/%66oo-bar and not IRI http://a.example/foo-bar. A term written as ex:%66oo-bar with a prefix @prefix ex: <http://a.example/> also designates the IRI http://a.example/%66oo-bar.

Update (according to comment below)

As @AndyS pointed out,

reserved character escape sequences consist of a '\' followed by one of ~.-!$&'()*+,;=/?#@%_ and represent the character to the right of the '\'.

So escaping with \ works for commas, i.e. you can write \,. Unfortunately, this still fails in the Virtuoso Web UI with

Virtuoso 37000 Error SP030: SPARQL compiler, line 0: Bad character '\' (0x5c) in SPARQL expression at '\'

So that should be a bug.