diff options
| author | Thomas Kluyver <takowl@gmail.com> | 2011-11-26 14:27:34 +0000 |
|---|---|---|
| committer | Thomas Kluyver <takowl@gmail.com> | 2011-11-26 14:27:34 +0000 |
| commit | 3a62086bb08bb7e083fe22778eb2da7b773f451e (patch) | |
| tree | fd9a03d4226428420de100c586b1022b9aa21d00 /rdflib/util.py | |
| parent | 2b8c0b69e09644c0cc22e3357e18f7fcba052381 (diff) | |
| download | rdflib-3a62086bb08bb7e083fe22778eb2da7b773f451e.tar.gz | |
Fix from_n3 for Python 3.
Diffstat (limited to 'rdflib/util.py')
| -rw-r--r-- | rdflib/util.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/rdflib/util.py b/rdflib/util.py index 95579270..33cef45c 100644 --- a/rdflib/util.py +++ b/rdflib/util.py @@ -140,7 +140,10 @@ def from_n3(s, default=None, backend=None): datatype = rest[3:-1] else: datatype = None - value = value.replace('\\"', '"').replace('\\\\', '\\').decode("unicode-escape") + value = value.replace('\\"', '"').replace('\\\\', '\\') + # Hack: this should correctly handle strings with either native unicode + # characters, or \u1234 unicode escapes. + value = value.encode("raw-unicode-escape").decode("unicode-escape") return Literal(value, language, datatype) elif s.startswith('{'): identifier = from_n3(s[1:-1]) |
