aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-21 22:58:53 +0000
committerDavid Robillard <d@drobilla.net>2011-01-21 22:58:53 +0000
commit187a60b1e0e80e44b5be52a7054585f0be35ca9f (patch)
tree5a9568f5c802d2796d82d13f294ecf391767731f /src/writer.c
parentfbf024e07f80f547677f9d39e64dd4bdd4be99f3 (diff)
downloadserd-187a60b1e0e80e44b5be52a7054585f0be35ca9f.tar.gz
serd-187a60b1e0e80e44b5be52a7054585f0be35ca9f.tar.bz2
serd-187a60b1e0e80e44b5be52a7054585f0be35ca9f.zip
Full rount-trip test coverage for Turtle reading and writing.
Fix writing UTF-8 URIs. Improved test coverage. git-svn-id: http://svn.drobilla.net/serd/trunk@28 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/writer.c b/src/writer.c
index eb6310a7..17179c60 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -115,10 +115,10 @@ write_text(SerdWriter writer, WriteContext ctx,
return false;
}
- if (!(writer->style & SERD_STYLE_ASCII)) {
- // Write UTF-8 input directly to UTF-8 output
- writer->sink(utf8, n_bytes, writer->stream);
- i += n_bytes - 1;
+ if (ctx == WRITE_STRING && !(writer->style & SERD_STYLE_ASCII)) {
+ // Write UTF-8 character directly to UTF-8 output
+ writer->sink(utf8 + i - 1, size, writer->stream);
+ i += size - 1;
continue;
}
@@ -370,6 +370,17 @@ serd_writer_set_base_uri(SerdWriter writer,
const SerdURI* uri)
{
writer->base_uri = *uri;
+ if (writer->syntax != SERD_NTRIPLES) {
+ if (writer->prev_g || writer->prev_s) {
+ writer->sink(" .\n\n", 4, writer->stream);
+ writer->prev_g = writer->prev_s =
+ writer->prev_p = writer->prev_o = 0;
+ }
+ writer->sink("@base ", 6, writer->stream);
+ writer->sink(" <", 2, writer->stream);
+ serd_uri_serialise(uri, writer->sink, writer->stream);
+ writer->sink("> .\n", 4, writer->stream);
+ }
}
SERD_API
@@ -379,6 +390,13 @@ serd_writer_set_prefix(SerdWriter writer,
const SerdString* uri)
{
if (writer->syntax != SERD_NTRIPLES) {
+ if (writer->prev_g || writer->prev_s) {
+ writer->sink(" .\n\n", 4, writer->stream);
+ writer->prev_g = 0;
+ writer->prev_s = 0;
+ writer->prev_p = 0;
+ writer->prev_o = 0;
+ }
writer->sink("@prefix ", 8, writer->stream);
writer->sink(name->buf, name->n_bytes - 1, writer->stream);
writer->sink(": <", 3, writer->stream);