ascii2desc(9)
π
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:
rh_string(9)usb_bus_init(9)usb_register_bus(9)usb_deregister_bus(9)register_root_hub(9)usb_calc_bus_time(9)usb_hcd_link_urb_to_ep(9)usb_hcd_check_unlink_urb(9)usb_hcd_unlink_urb_from_ep(9)usb_hcd_giveback_urb(9)usb_hcd_alloc_bandwidth(9)usb_hcd_reset_endpoint(9)usb_alloc_streams(9)usb_free_streams(9)usb_hcd_resume_root_hub(9)usb_bus_start_enum(9)usb_hcd_irq(9)usb_hc_died(9)usb_create_shared_hcd(9)usb_create_hcd(9)usb_stop_hcd(9)usb_add_hcd(9)usb_remove_hcd(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms