From a0387d66372beee3940c778031e94940acf10c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Tue, 8 Jul 2025 17:43:04 +0200 Subject: [PATCH] audio/gap: Use strtoutf8 for GAP device name Truncate the string to first character before invalid UTF-8 one instead of replacing non ascii characters by spaces. --- profiles/gap/gas.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c index a4831d38f..26b5e1af4 100644 --- a/profiles/gap/gas.c +++ b/profiles/gap/gas.c @@ -69,21 +69,12 @@ static void gas_free(struct gas *gas) static char *name2utf8(const uint8_t *name, uint16_t len) { char utf8_name[HCI_MAX_NAME_LENGTH + 2]; - int i; - - if (g_utf8_validate((const char *) name, len, NULL)) - return g_strndup((char *) name, len); len = MIN(len, sizeof(utf8_name) - 1); memset(utf8_name, 0, sizeof(utf8_name)); strncpy(utf8_name, (char *) name, len); - - /* Assume ASCII, and replace all non-ASCII with spaces */ - for (i = 0; utf8_name[i] != '\0'; i++) { - if (!isascii(utf8_name[i])) - utf8_name[i] = ' '; - } + strtoutf8(utf8_name, len); /* Remove leading and trailing whitespace characters */ g_strstrip(utf8_name); -- 2.47.3