From b70bf938c230bb5e8aafe95094975a8e10109876 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 10 Oct 2014 21:17:40 +0200 Subject: util/UTF8: add SequenceLengthUTF8() --- src/util/UTF8.hxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/util/UTF8.hxx') diff --git a/src/util/UTF8.hxx b/src/util/UTF8.hxx index d3d694f6b..82d324f3e 100644 --- a/src/util/UTF8.hxx +++ b/src/util/UTF8.hxx @@ -42,6 +42,22 @@ gcc_pure gcc_nonnull_all bool ValidateUTF8(const char *p); +/** + * @return the number of the sequence beginning with the given + * character, or 0 if the character is not a valid start byte + */ +gcc_const +size_t +SequenceLengthUTF8(char ch); + +/** + * @return the number of the first sequence in the given string, or 0 + * if the sequence is malformed + */ +gcc_pure +size_t +SequenceLengthUTF8(const char *p); + /** * Convert the specified string from ISO-8859-1 to UTF-8. * -- cgit v1.2.3