Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N3 literal parsing failes on \t #11

Closed
ghost opened this issue Feb 20, 2012 · 0 comments
Closed

N3 literal parsing failes on \t #11

ghost opened this issue Feb 20, 2012 · 0 comments

Comments

@ghost
Copy link

ghost commented Feb 20, 2012

hannes.g...@gmail.com, 2008-01-23T10:32:30.000Z

When I try to parse an N3, I get an error when a literal contains a \t. But
\t is defined to be in N3 strings.

I suspect the failure is in n3proc's unquote:

>>> from rdflib.syntax.parsers.n3p.n3proc import unquote
>>> unquote("\t")
Traceback (most recent call last):
  File "", line 1, in 
  File "build/bdist.linux-i686/egg/rdflib/syntax/parsers/n3p/n3proc.py",
line 85, in unquote
rdflib.syntax.parsers.n3p.n3proc.ParseError: Illegal literal character: '\t'

Comment 1 by eike...@gmail.com
This is actually correct, I believe, since "\t" should be escaped as r"\t". For example unquote(r"\t") will give you 
"\t" -- and unquote("\t") (AKA an actual tab character) will give the above error.

In looking into this issue I did notice Literal's n3 method is not correctly escaping "\t". Literal("\t").n3() should be 
"\\t" which is the same as r"\t".


Comment 2 by eike...@gmail.com



Comment 3 by gromgull
Eikeon is right - this seem to work fine

{{{
g=rdflib.graph.Graph()
g.parse(StringIO.StringIO(r'  "Gunnar\tlikes chese". '),
format="n3")
print g.serialize()


  
    <_4:name>Gunnar likes chese
  

}}}
@ghost ghost closed this as completed Feb 20, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants