ascii2desc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ascii2desc β€” like, the ascii2desc(9) page, bestie ✨

okay so this is ascii2desc(9) from the Kernel API Manual, and honestly? it's a little helper that's carrying the whole USB descriptor operation on its back 🫢


🌸 NAME 🌸

ascii2desc β€” the helper routine that's out here producing UTF-16LE string descriptors for you, no cap πŸ’–


✨ SYNOPSIS ✨

unsigned ascii2desc (char const *s , u8 *buf , unsigned len );

that's the whole vibe check β€” three args, one unsigned coming back at you 🌈


πŸŽ€ ARGUMENTS πŸŽ€

  • s β€” a null-terminated ASCII string. and yeah, "ASCII" is doing a little bit of a stretch here, because it's actually ISO-8859-1 😭 character for character, that's what the page says.
  • buf β€” the buffer where the USB string descriptor goes. it's giving header + UTF-16LE energy πŸ’…
  • len β€” the length, in bytes, of that descriptor buffer. and yes, it may be odd πŸ™ˆ they said it, not me.

⭐ RETURN ⭐

it hands back the number of bytes it filled in, and the math is:

2 + 2*strlen(s)

...or len, whichever is less. that's it, that's the whole answer, periodt πŸ‘‘


πŸ’€ NOTE πŸ’€

okay this part lowkey matters so pay attention bestie:

USB String descriptors can contain at most 126 characters. input strings longer than that get truncated. 😭 so don't come crying to me when your extra-long string gets chopped.

πŸ¦‹ SEE ALSO πŸ¦‹

the kernel file that's the main character here is ./drivers/usb/core/hcd.c, and then it's a whole friend group of references β€” every single one, iykyk:

like, go read them, they're iconic too πŸ’œ


anyway that's the page!! this one lives in ./drivers/usb/core, dated October 2026, and it's filed under ascii2desc(9) β€” mwah, go forth and convert your strings to UTF-16LE bestie πŸ§šβ€β™€οΈπŸ’–βœ¨

πŸ“¦ where this page comes from