fixed confusion of byteCount and charCount in ServerFont::StringWidth(), just in case anyone really uses it later. Added UTF8CountChars() to moreUTF8.h, but then I didn't need it...

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12750 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-05-20 23:51:33 +00:00
parent 81cc749f6b
commit 7220b138f2
3 changed files with 58 additions and 26 deletions
+29 -14
View File
@@ -24,20 +24,6 @@ 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)
{
@@ -55,4 +41,33 @@ UTF8PreviousCharLen(const char *text, const char *limit)
return text - ptr;
}
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
UTF8CountChars(const char *text, int32 numBytes)
{
const char* ptr = text;
const char* last = ptr + numBytes - 1;
uint32 count = 0;
while (ptr <= last) {
ptr += UTF8NextCharLen(ptr);
count++;
}
return count;
}
#endif