Linux Sound subsystem development
 help / color / mirror / Atom feed
* Incorrect automatic ALSA card ID when unicode is at play
@ 2024-10-02 16:54 Barnabás Pőcze
  2024-10-02 18:00 ` Jaroslav Kysela
  0 siblings, 1 reply; 3+ messages in thread
From: Barnabás Pőcze @ 2024-10-02 16:54 UTC (permalink / raw)
  To: linux-sound@vger.kernel.org, Jaroslav Kysela, Takashi Iwai

Hi


When `snd_card::id` is not specified explicitly it is determined automatically
in `sound/core/init.c:snd_card_register()` as follows:

  if (*card->id) {
    // ...
  } else {
    /* create an id from either shortname or longname */
    const char *src;

    src = *card->shortname ? card->shortname : card->longname;
    snd_card_set_id_no_lock(card, src,
                                  retrieve_id_from_card_name(src));
  }

However, `snd_card_set_id_no_lock()`, or more specifically the `copy_valid_id_string()`
function that it calls does not seem to copy very well with utf-8.

For example, based on the report at https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4135
where `card->shortname="Redmi 电脑音箱"`, `card->id` will be set to \xE7\xE8\xE9\xE7,
which are the first bytes of the symbols in the suffix "电脑音箱" because only those
bytes of the string satisfy the `isalnum()` check in `copy_valid_id_string()`.

I am not sure what kind of 8-bit character set `isalnum()` is basing these results on, but
it certainly does not mix well with utf-8 in this scenario at least.


Regards,
Barnabás Pőcze

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-02 19:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02 16:54 Incorrect automatic ALSA card ID when unicode is at play Barnabás Pőcze
2024-10-02 18:00 ` Jaroslav Kysela
2024-10-02 19:36   ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox