mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Minor improvement to to_utf8
This commit is contained in:
parent
004541f5cf
commit
71e5a15298
@ -83,12 +83,28 @@ static size_t getLength(const char *arr, const char* input, bool &ascii)
|
|||||||
{
|
{
|
||||||
ascii = true;
|
ascii = true;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
unsigned char inp = *input;
|
const char* ptr = input;
|
||||||
while(inp)
|
unsigned char inp = *ptr;
|
||||||
|
|
||||||
|
// Do away with the ascii part of the string first (this is almost
|
||||||
|
// always the entire string.)
|
||||||
|
while(inp && inp < 128)
|
||||||
|
inp = *(++ptr);
|
||||||
|
len += (ptr-input);
|
||||||
|
|
||||||
|
// If we're not at the null terminator at this point, then there
|
||||||
|
// were some non-ascii characters to deal with. Go to slow-mode for
|
||||||
|
// the rest of the string.
|
||||||
|
if(inp)
|
||||||
{
|
{
|
||||||
if(inp > 127) ascii = false;
|
ascii = false;
|
||||||
len += arr[inp*6];
|
while(inp)
|
||||||
inp = *(++input);
|
{
|
||||||
|
// Find the translated length of this character in the
|
||||||
|
// lookup table.
|
||||||
|
len += arr[inp*6];
|
||||||
|
inp = *(++ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user