title: Why does my binary response add spaces between characters?
body: <p>I'm using Node, Express, KNEX, and the tedious drivers to interface with SQL Server.  I execute a stored procedure which returns a <code>varbinary(max)</code> response.  I cannot alter this stored procedure.</p>
  <p>When I capture the response and attempt to convert it to a string, which will be sent back to the browser, the expected response has a ton of white space characters between each character.</p>
  <p>What I am doing wrong?</p>
  <pre><code>        // const { StringDecoder } = require('string_decoder');
          // const decoder = new StringDecoder('utf8');
  
          const response = await Webservice.spWebservice(params)  //exec stored procedure
          let { Response_Binary } = response;
  
          console.log(Response_Binary)
  
          const buff = Buffer.from(Response_Binary)
          console.log(buff);
          console.log(buff.toString());
  
  
          // console.log(decoder.write(buff));
          // console.log(decoder.end(buff));
  
  </code></pre>
  <p><strong>Actual SQL Server response (via KNEX):</strong></p>
  <p><code>&lt;Buffer 3c 00 3f 00 78 00 6d 00 6c 00 20 00 76 00 65 00 72 00 73 00 69 00 6f 00 6e 00 3d 00 22 00 31 00 2e 00 30 00 22 00 20 00 65 00 6e 00 63 00 6f 00 64 00 ... 764 more bytes&gt;</code></p>
  <p><strong><code>Buffer.from()</code></strong></p>
  <p><code>&lt;Buffer 3c 00 3f 00 78 00 6d 00 6c 00 20 00 76 00 65 00 72 00 73 00 69 00 6f 00 6e 00 3d 00 22 00 31 00 2e 00 30 00 22 00 20 00 65 00 6e 00 63 00 6f 00 64 00 ... 764 more bytes&gt;</code></p>
  <p><strong><code>toString()</code></strong></p>
  <p><code>&lt; ? x m l   v e r s i o n = &quot; 1 . 0 &quot;   e n c o d i n g = &quot; U T F - 1 6 &quot; ? &gt; &lt; x m l &gt; &lt; s t a t u s &gt; &lt; r e s u l t &gt; S u c c e s s &lt; / r e s u l t &gt; &lt; m e s s a g e &gt; &lt; / m e s s a g e &gt; &lt; / s t a t u s &gt; &lt; d a t a &gt; &lt;   p p A c t i o n &gt; i n i t &lt; / A p p A c t i o n &gt; &lt; U s e r I n f o &gt; &lt; U s e r &gt;  &lt; / U s e r &gt; &lt; A d d r e s s &gt; : : 1 &lt; / A d d r e s s &gt; &lt; U s e r A g e n t &gt; M o z i l l a / 5 . 0   ( W i n d o w s   N T     0 . 0 ;   W i n 6 4 ;   x 6 4 )   A p p l e W e b K i t / 5 3 7 . 3 6   ( K H T M L ,   l i k e   G e c k o )   C h r o m e / 9 2 . 0 . 4 5 1 5 . 1 3 1   S a f a r i / 5 3 7 . 3 6 &lt; / U s e r A g e n t &gt; &lt; C a l l e r &gt; &lt;   C a l l e r &gt; &lt; R e f e r r e r &gt; &lt; / R e f e r r e r &gt; &lt; O p t i o n s &gt; &lt; / O p t i o n s &gt; &lt; / U s e r I n f o &gt; &lt; / d a t a &gt; &lt; / x m l &gt;</code>
  `</p>
  <p><strong>Things I have tried [updated]:</strong></p>
  <pre><code>        let convertedBuffer = Buffer.from(Response_Binary, 'binary').toString();
          console.log(convertedBuffer) // extra spaces between characters
  
          convertedBuffer = Buffer.from(Response_Binary, 'ascii').toString();
          console.log(convertedBuffer) // extra spaces between characters
          
          convertedBuffer = Buffer.from(Response_Binary, 'utf-8').toString();
          console.log(convertedBuffer) // extra spaces between characters
          
          convertedBuffer = Buffer.from(Response_Binary, 'utf8').toString();
          console.log(convertedBuffer) // extra spaces between characters
          
          convertedBuffer = Buffer.from(Response_Binary, 'base64').toString();
          console.log(convertedBuffer) // extra spaces between characters
          
          convertedBuffer = Buffer.from(Response_Binary, 'utf16le').toString();
          console.log(convertedBuffer) // extra spaces between characters
  
  
          console.log(`Is Response_Binary from KNEX/MSSQL actually a buffer? ===&gt;&gt;&gt; `)
          console.log(Buffer.isBuffer(Response_Binary)); // returns true;
  
  
          console.log(Response_Binary.toString('ascii'));   // extra spaces between characters
          console.log(Response_Binary.toString('utf-8'));   // extra spaces between characters
          console.log(Response_Binary.toString('utf8'));    // extra spaces between characters
          console.log(Response_Binary.toString('base64'));  // not for humans
          console.log(Response_Binary.toString('utf16le')); // CORRECT ANSWER!!!!!
  
  
  </code></pre>
  <p><code>Response_Binary.toString('utf16le')</code> returns:</p>
  <p><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&gt;&lt;xml&gt;&lt;status&gt;&lt;result&gt;Success&lt;/result&gt;&lt;message&gt;&lt;/message&gt;&lt;/status&gt;&lt;data&gt;&lt;AppAction&gt;init&lt;/AppAction&gt;&lt;UserInfo&gt;&lt;User&gt;redacted&lt;/User&gt;&lt;Address&gt;::1&lt;/Address&gt;&lt;UserAgent&gt;Mozilla/5.0 (Windows NT  10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36&lt;/UserAgent&gt;&lt;Caller&gt;&lt;/Caller&gt;&lt;Referrer&gt;&lt;/Referrer&gt;&lt;Options&gt;&lt;/Options&gt;&lt;/UserInfo&gt;&lt;/data&gt;&lt;/xml&gt;</code></p>