aboutsummaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2019-10-28 07:38:22 +1000
committerSteve Bennett <steveb@workware.net.au>2019-10-28 07:43:47 +1000
commit338f5b5681181c771646b6f225f103be4b14ea03 (patch)
treef5f22e66725e52e6d281ed525f8f6643b22eddc8 /utf8.h
parent27ed764fa513ea55f92ea1e6be500fb22b30007b (diff)
downloadjimtcl-338f5b5681181c771646b6f225f103be4b14ea03.zip
jimtcl-338f5b5681181c771646b6f225f103be4b14ea03.tar.gz
jimtcl-338f5b5681181c771646b6f225f103be4b14ea03.tar.bz2
utf8_strlen: Improve performance
Use utf8_charlen() rather than utf8_tounicode() Note that utf8_charlen() now returns 1 instead of -1 for an invalid utf-8 start byte. Reported-by: dbohdan <dbohdan@dbohdan.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'utf8.h')
-rw-r--r--utf8.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/utf8.h b/utf8.h
index 40fc95f..9970683 100644
--- a/utf8.h
+++ b/utf8.h
@@ -49,9 +49,8 @@ int utf8_fromunicode(char *p, unsigned uc);
/**
* Returns the length of the utf-8 sequence starting with 'c'.
*
- * Returns 1-4, or -1 if this is not a valid start byte.
- *
- * Note that charlen=4 is not supported by the rest of the API.
+ * Returns 1-4.
+ * If 'c' is not a valid start byte, returns 1.
*/
int utf8_charlen(int c);