title: How can I convert an NSString with printer commands into NSData
body: <p>I need to send a series of printer commands to a Sato barcode printer.  For example:</p>
  
  <pre><code>&lt;ESC&gt;A
  &lt;ESC&gt;H0120
  &lt;ESC&gt;V0060
  &lt;ESC&gt;$B,180,180,0
  &lt;ESC&gt;$=Information
  ...
  </code></pre>
  
  <p>I have an open tcp/ip connection to the printer and simply want to write an NSData object, such as:</p>
  
  <pre><code>[connection write:data error:error];
  </code></pre>
  
  <p>wheras data is an NSData object.  I realize that I can insert the escape into a string using the binary value with \x1B.  For example:</p>
  
  <pre><code>NSString *printString=[[NSString alloc]initWithString:@"\x1BA\X1BH0120\X1BV0060\X1B$B,180,180,0/X1B$=Information"];  
  </code></pre>
  
  <p>The problem I'm having is that I don't know how to translate my string to NSData for the write.</p>
  
  <p>I appreciate any suggestions.</p>