diff options
-rw-r--r-- | src/writer.c | 3 | ||||
-rw-r--r-- | tests/test-long-string.out | 1 | ||||
-rw-r--r-- | tests/test-long-string.ttl | 7 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/writer.c b/src/writer.c index a9209f80..735dcaaf 100644 --- a/src/writer.c +++ b/src/writer.c @@ -145,7 +145,8 @@ write_text(SerdWriter* writer, TextContext ctx, if ((in & 0x80) == 0) { // Starts with `0' size = 1; c = in & 0x7F; - if (in_range(c, 0x20, 0x7E) || (ctx != WRITE_URI && is_space(c))) { + if (in_range(c, 0x20, 0x7E) + || (is_space(c) && ctx == WRITE_LONG_STRING)) { sink(&in, 1, writer); // Print ASCII character } else { snprintf(escape, 7, "\\u%04X", c); diff --git a/tests/test-long-string.out b/tests/test-long-string.out new file mode 100644 index 00000000..ba6be49c --- /dev/null +++ b/tests/test-long-string.out @@ -0,0 +1 @@ +<http://example.org/thing> <http://example.org/greeting> "This is a\nlong string\nwith\n tabs\nand spaces." . diff --git a/tests/test-long-string.ttl b/tests/test-long-string.ttl new file mode 100644 index 00000000..7da44b4b --- /dev/null +++ b/tests/test-long-string.ttl @@ -0,0 +1,7 @@ +@prefix : <http://example.org/> . + +:thing :greeting """This is a +long string +with + tabs +and spaces.""" .
\ No newline at end of file |