1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>usb_string</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux-USB Host Side API"><link rel="up" href="usbcore.html" title="Chapter 5. USB Core APIs"><link rel="prev" href="API-usb-get-descriptor.html" title="usb_get_descriptor"><link rel="next" href="API-usb-get-status.html" title="usb_get_status"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">usb_string</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-usb-get-descriptor.html">Prev</a> </td><th width="60%" align="center">Chapter 5. USB Core APIs</th><td width="20%" align="right"> <a accesskey="n" href="API-usb-get-status.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-usb-string"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>usb_string — 2 returns UTF-8 version of a string descriptor 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">usb_string </b>(</code></td><td>struct usb_device * <var class="pdparam">dev</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">index</var>, </td></tr><tr><td> </td><td>char * <var class="pdparam">buf</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1116223036"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>dev</code></em></span></dt><dd><p> 4 the device whose string descriptor is being retrieved 5 </p></dd><dt><span class="term"><em class="parameter"><code>index</code></em></span></dt><dd><p> 6 the number of the descriptor 7 </p></dd><dt><span class="term"><em class="parameter"><code>buf</code></em></span></dt><dd><p> 8 where to put the string 9 </p></dd><dt><span class="term"><em class="parameter"><code>size</code></em></span></dt><dd><p> 10 how big is <span class="quote">“<span class="quote">buf</span>”</span>? 11 </p></dd></dl></div></div><div class="refsect1"><a name="idp1116227772"></a><h2>Context</h2><p> 12 !in_interrupt () 13</p></div><div class="refsect1"><a name="idp1116228348"></a><h2>Description</h2><p> 14 This converts the UTF-16LE encoded strings returned by devices, from 15 <code class="function">usb_get_string_descriptor</code>, to null-terminated UTF-8 encoded ones 16 that are more usable in most kernel contexts. Note that this function 17 chooses strings in the first language supported by the device. 18 </p><p> 19 20 This call is synchronous, and may not be used in an interrupt context. 21</p></div><div class="refsect1"><a name="idp1116229732"></a><h2>Return</h2><p> 22 length of the string (>= 0) or usb_control_msg status (< 0). 23</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-usb-get-descriptor.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="usbcore.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-usb-get-status.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">usb_get_descriptor</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">usb_get_status</span></td></tr></table></div></body></html> 24