operator ^ for last defined person

This commit is contained in:
Venelin
2024-06-15 13:48:08 +03:00
committed by vrd
parent a096a2a34c
commit 4d61963dae
8 changed files with 91 additions and 63 deletions
+4 -4
View File
@@ -81,11 +81,11 @@ void Person::displayInfo()const
}
static U16 strUtf8Symbols(const char* str)
static U16 Utf8SymbolsCount(const string& str)
{
U16 num = 0;
for(; *str != '\0'; ++str)
num += ((*str & 0xC0) != 0x80);
for(char c: str)
num += ((c & 0xC0) != 0x80); // bytes that start with 0 are single, 11 are multiple, 10 are sucessors
return num;
}
@@ -113,7 +113,7 @@ U16 Person::draw(const I16 drawY, const I16 drawX, bool selected, bool hasSpouse
}
}
const U16 width = strUtf8Symbols(display_name.data()) + 4; /* pad width */
const U16 width = Utf8SymbolsCount(display_name) + 4; /* pad width */
if(willBeVisible(drawY, drawX, BOX_HEIGHT, width))
{