Move wxIsUTF8Prefix() to convauto.cpp
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/convauto.h"
|
||||
#include "wx/private/unicode.h"
|
||||
|
||||
// we use latin1 by default as it seems the least bad choice: the files we need
|
||||
// to detect input of don't always come from the user system (they are often
|
||||
@@ -266,6 +267,26 @@ bool wxConvAuto::InitFromInput(const char *src, size_t len)
|
||||
return true;
|
||||
}
|
||||
|
||||
// checks if the input can be the beginning of a valid UTF-8 string
|
||||
static bool wxIsUTF8Prefix(const char *src, size_t len)
|
||||
{
|
||||
unsigned char l;
|
||||
for ( size_t i = 0; i < len; ++i )
|
||||
{
|
||||
l = tableUtf8Lengths[(unsigned char)src[i]];
|
||||
if ( !l )
|
||||
return false; // invalid leading byte
|
||||
while ( --l )
|
||||
{
|
||||
if ( ++i == len )
|
||||
return true; // truncated sequence
|
||||
if ( (src[i] & 0xC0) != 0x80 )
|
||||
return false; // invalid continuation byte
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t
|
||||
wxConvAuto::ToWChar(wchar_t *dst, size_t dstLen,
|
||||
const char *src, size_t srcLen) const
|
||||
|
||||
Reference in New Issue
Block a user