diff options
author | David Robillard <d@drobilla.net> | 2012-02-21 00:45:22 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-02-21 00:45:22 +0000 |
commit | 945ce48b31a50e5973bdf97b47336a9bcd2410bf (patch) | |
tree | aa2b5226f208c5cb4b20e392949ad495632fccdd | |
parent | ae46d9dfd96b05ddf876465f2c5a8cdd5f742ab0 (diff) | |
download | serd-945ce48b31a50e5973bdf97b47336a9bcd2410bf.tar.gz serd-945ce48b31a50e5973bdf97b47336a9bcd2410bf.tar.bz2 serd-945ce48b31a50e5973bdf97b47336a9bcd2410bf.zip |
Tidy.
git-svn-id: http://svn.drobilla.net/serd/trunk@314 490d8e77-9747-427b-9fa3-0b8f29cee8a0
-rw-r--r-- | src/writer.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/writer.c b/src/writer.c index 270bd16f..587a3e3f 100644 --- a/src/writer.c +++ b/src/writer.c @@ -185,10 +185,9 @@ write_text(SerdWriter* writer, TextContext ctx, uint32_t c = 0; size_t size = 0; if ((in & 0x80) == 0) { // Starts with `0' - size = 1; c = in & 0x7F; if (in_range(c, 0x20, 0x7E) - || (is_space(c) && ctx == WRITE_LONG_STRING)) { + || (is_space(c) && ctx == WRITE_LONG_STRING)) { sink(&in, 1, writer); // Print ASCII character } else { snprintf(escape, sizeof(escape), "\\u%04X", c); @@ -197,13 +196,13 @@ write_text(SerdWriter* writer, TextContext ctx, continue; } else if ((in & 0xE0) == 0xC0) { // Starts with `110' size = 2; - c = in & 0x1F; + c = in & 0x1F; } else if ((in & 0xF0) == 0xE0) { // Starts with `1110' size = 3; - c = in & 0x0F; + c = in & 0x0F; } else if ((in & 0xF8) == 0xF0) { // Starts with `11110' size = 4; - c = in & 0x07; + c = in & 0x07; } else { fprintf(stderr, "Invalid UTF-8: %X\n", in); const uint8_t replacement_char[] = { 0xEF, 0xBF, 0xBD }; @@ -221,8 +220,7 @@ write_text(SerdWriter* writer, TextContext ctx, #define READ_BYTE() \ in = utf8[i++] & 0x3f; \ - c <<= 6; \ - c |= in; + c = (c << 6) | in; switch (size) { case 4: READ_BYTE(); |