Fixed UTF-8 passwords for DeviceCommunicationControl to hold up to 20 UTF-8 characters (#767)

This commit is contained in:
Tomasz Kazimierz Motyl
2024-09-19 14:37:36 +01:00
committed by GitHub
parent b9adcc8097
commit f4325f00b5
6 changed files with 40 additions and 5 deletions
+23
View File
@@ -587,6 +587,29 @@ bool characterstring_ansi_same(
return same_status;
}
/**
* Returns number of UTF8 code points in a character string.
*
* @param dest Pointer to the string to count the UTF8 code points.
*
* @return Length of the character string in utf8 codepoints
*/
size_t characterstring_utf8_length(const BACNET_CHARACTER_STRING *str)
{
size_t count = 0;
int i = 0;
while ((i < MAX_CHARACTER_STRING_BYTES) && (str->value[i] != '\0')) {
if ((str->value[i] & 0xc0) != 0x80) {
count++;
}
i++;
}
return count;
}
/**
* Append some characters to the end of the characterstring
*