diff options
author | David Robillard <d@drobilla.net> | 2016-07-09 11:29:44 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-07-09 11:29:44 -0400 |
commit | 443f470383dc3acba0fde7b705e8ff81a7c49595 (patch) | |
tree | 1b6a094465f3ec7844695aaf54722cfd65791e87 /src/string.c | |
parent | c7715b8b5ee48297c9a4fc0831556921d5f78fb0 (diff) | |
download | serd-443f470383dc3acba0fde7b705e8ff81a7c49595.tar.gz serd-443f470383dc3acba0fde7b705e8ff81a7c49595.tar.bz2 serd-443f470383dc3acba0fde7b705e8ff81a7c49595.zip |
Fix construction of URIs with UTF-8 characters
Diffstat (limited to 'src/string.c')
-rw-r--r-- | src/string.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/string.c b/src/string.c index a1a1dff1..1e653795 100644 --- a/src/string.c +++ b/src/string.c @@ -1,5 +1,5 @@ /* - Copyright 2011-2012 David Robillard <http://drobilla.net> + Copyright 2011-2016 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -40,25 +40,28 @@ SERD_API size_t serd_strlen(const uint8_t* str, size_t* n_bytes, SerdNodeFlags* flags) { - size_t n_chars = 0; - size_t i = 0; - *flags = 0; + size_t n_chars = 0; + size_t i = 0; + SerdNodeFlags f = 0; for (; str[i]; ++i) { if ((str[i] & 0xC0) != 0x80) { // Does not start with `10', start of a new character ++n_chars; switch (str[i]) { case '\r': case '\n': - *flags |= SERD_HAS_NEWLINE; + f |= SERD_HAS_NEWLINE; break; case '"': - *flags |= SERD_HAS_QUOTE; + f |= SERD_HAS_QUOTE; } } } if (n_bytes) { *n_bytes = i; } + if (flags) { + *flags = f; + } return n_chars; } |