mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 12:30:32 +00:00
- do not use iswspace to check raw UTF-8.
At least under MSVC this function reports 0x85 as whitespace, but it is a continuation byte for UTF-8 sequences and may not be treated as whitespace. (patch by Graf)
This commit is contained in:
parent
8a9ffb3031
commit
a31c9273dd
1 changed files with 7 additions and 4 deletions
|
@ -290,6 +290,9 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
|
|||
bool lastWasSpace = false;
|
||||
int kerning = font->GetDefaultKerning ();
|
||||
|
||||
// The real isspace is a bit too badly defined, so use our own one
|
||||
auto myisspace = [](int ch) { return ch == '\t' || ch == '\r' || ch == '\n' || ch == ' '; };
|
||||
|
||||
w = 0;
|
||||
|
||||
while ( (c = GetCharFromString(string)) )
|
||||
|
@ -319,7 +322,7 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
|
|||
continue;
|
||||
}
|
||||
|
||||
if (iswspace(c))
|
||||
if (myisspace(c))
|
||||
{
|
||||
if (!lastWasSpace)
|
||||
{
|
||||
|
@ -352,12 +355,12 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
|
|||
start = space;
|
||||
space = NULL;
|
||||
|
||||
while (*start && iswspace (*start) && *start != '\n')
|
||||
while (*start && myisspace (*start) && *start != '\n')
|
||||
start++;
|
||||
if (*start == '\n')
|
||||
start++;
|
||||
else
|
||||
while (*start && iswspace (*start))
|
||||
while (*start && myisspace (*start))
|
||||
start++;
|
||||
string = start;
|
||||
}
|
||||
|
@ -375,7 +378,7 @@ TArray<FBrokenLines> V_BreakLines (FFont *font, int maxwidth, const uint8_t *str
|
|||
while (s < string)
|
||||
{
|
||||
// If there is any non-white space in the remainder of the string, add it.
|
||||
if (!iswspace (*s++))
|
||||
if (!myisspace (*s++))
|
||||
{
|
||||
auto i = Lines.Reserve(1);
|
||||
breakit (&Lines[i], font, start, string, linecolor);
|
||||
|
|
Loading…
Reference in a new issue