gjhiggins/rdflib — Issue #77: nt serializer encodes output as UTF-8, not python string literal encoding
Author: gjhiggins
Created: 2011-10-19 01:13:20+00:00
State: closed
Labels: Component-Serializer, Milestone-Release2.5

Originally filed by staffan....@gmail.com on 2009-07-27T09:31:10

What steps will reproduce the problem?

>>> from rdflib import URIRef, Literal
>>> from rdflib.Graph import Graph
>>> g = Graph()
>>> g.add((URIRef("foo"), URIRef("foo"), Literal(u'Räksmörgås')))
>>> g.serialize(format="nt")

Expected output:

' "R\u00E4ksm\u00F6rg\u00E5s.\n'

Actual output:

' "R\xc3\xa4ksm\xc3\xb6rg\xc3\xa5s".\n'

What version of the product are you using? On what operating system?

2.4.2, on Windows

Please provide any additional information below.

When attempting to read the produced nt file, the default file encoding
(latin-1) is used rather than utf-8, resulting in incorrectly escaped
literals.