summaryrefslogtreecommitdiffstats
path: root/sord/sord.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-15 14:52:47 -0400
committerDavid Robillard <d@drobilla.net>2016-03-15 14:52:47 -0400
commitce981fefe0c4d4f9c871b574a92eec06e3149e3e (patch)
tree92d7bf7e914cc3b9effc82de64350f0d1bc2bc6e /sord/sord.h
parent19cd4c95e10ec83f8fbf41809e9d3688c64bd2d8 (diff)
downloadsord-ce981fefe0c4d4f9c871b574a92eec06e3149e3e.tar.gz
sord-ce981fefe0c4d4f9c871b574a92eec06e3149e3e.tar.bz2
sord-ce981fefe0c4d4f9c871b574a92eec06e3149e3e.zip
Make sord_node_get_counted return byte count
Also clarify formerly ambiguous documentation, and add sord_node_get_string_measured to get both byte and character counts. Technically, this breaks behaviour, but most (if not all) existing code that uses this function was actually expecting a byte count. This is unsurprising since a UTF-8 character count is almost always useless. This approach causes less problems in reality, since it fixes broken behaviour in the wild without requiring any changes in user code.
Diffstat (limited to 'sord/sord.h')
-rw-r--r--sord/sord.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/sord/sord.h b/sord/sord.h
index dd671de..e93cff8 100644
--- a/sord/sord.h
+++ b/sord/sord.h
@@ -248,11 +248,21 @@ const uint8_t*
sord_node_get_string(const SordNode* node);
/**
- Return the string value of a node, and set `len` to its length.
+ Return the string value of a node, and set `bytes` to its length in bytes.
*/
SORD_API
const uint8_t*
-sord_node_get_string_counted(const SordNode* node, size_t* len);
+sord_node_get_string_counted(const SordNode* node, size_t* bytes);
+
+/**
+ Return the string value of a node, and set `bytes` to its length in bytes,
+ and `count` to its length in characters.
+*/
+SORD_API
+const uint8_t*
+sord_node_get_string_measured(const SordNode* node,
+ size_t* bytes,
+ size_t* chars);
/**
Return the language of a literal node (or NULL).