mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
utf8_nextchar: Don't use a pointed-to variable as a loop counter.
This commit is contained in:
1 parent
07658ef41a
commit
85dbc6b6aa
1 file changed
+5
-3
@@ -219,13 +219,15 @@ int u8_strlen(const char *s)
|
||||
}
|
||||
|
||||
/* reads the next utf-8 sequence out of a string, updating an index */
|
||||
uint32_t u8_nextchar(const char *s, int *i) {
|
||||
uint32_t u8_nextchar(const char *s, int *index) {
|
||||
uint32_t ch = 0;
|
||||
int sz = 0;
|
||||
int i = *index;
|
||||
do {
|
||||
ch = (ch << 6) + (unsigned char)s[(*i)++];
|
||||
ch = (ch << 6) + (unsigned char)s[i++];
|
||||
sz++;
|
||||
} while (s[*i] && ((s[*i]) & 0xC0) == 0x80);
|
||||
} while (s[i] && ((s[i]) & 0xC0) == 0x80);
|
||||
*index = i;
|
||||
return ch - offsetsFromUTF8[sz - 1];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user