From 1db49f8a7a0ec3af231aae8f27cdb49e9326104e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 13 May 2005 17:30:59 +0000 Subject: [PATCH] added a function to count the bytes in a string if the number of UTF8 chars is already known git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12661 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/interface/moreUTF8.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/headers/private/interface/moreUTF8.h b/headers/private/interface/moreUTF8.h index 88ca0172f7..758a313b72 100644 --- a/headers/private/interface/moreUTF8.h +++ b/headers/private/interface/moreUTF8.h @@ -24,6 +24,19 @@ UTF8NextCharLen(const char *text) return ptr - text; } +static inline uint32 +UTF8CountBytes(const char *text, uint32 numChars) +{ + const char *ptr = text; + + while (numChars) { + ptr += UTF8NextCharLen(ptr); + numChars--; + } + + return ptr - text; +} + static inline uint32 UTF8PreviousCharLen(const char *text, const char *limit)