mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-11 17:05:41 +00:00
Don't bother re-encoding Latin1 characters in the ASCII range
(cherry picked from commit 6150b5b3cb)
This commit is contained in:
parent
2660da6f5c
commit
4700fbcbdf
3 changed files with 13 additions and 40 deletions
|
|
@ -621,42 +621,6 @@ SDL_utf8strnlen(const char *str, size_t bytes)
|
|||
return retval;
|
||||
}
|
||||
|
||||
SDL_bool SDL_utf8valid(const char *str, size_t bytes)
|
||||
{
|
||||
while (*str && bytes > 0) {
|
||||
Uint8 ch = (Uint8)*str;
|
||||
|
||||
if (ch <= 0x7F) {
|
||||
++str;
|
||||
--bytes;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UTF8_IsLeadByte(ch)) {
|
||||
size_t left = UTF8_TrailingBytes(ch);
|
||||
if (bytes < left) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
++str;
|
||||
--bytes;
|
||||
|
||||
while (left-- > 0) {
|
||||
ch = (Uint8)*str;
|
||||
if (!UTF8_IsTrailingByte(ch)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
++str;
|
||||
--bytes;
|
||||
}
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
size_t
|
||||
SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue