title: How to insert \x into NSString object
body: <p>I am trying to print data to a bluetooth printer.  In order to do this I need to send hex to the printer.  I have been successfully doing this by sending commands such as</p>
  
  <p>@"\x1b\x7b\x01"
  @"\x1b\x7b\x00"</p>
  
  <p>These are all static commands.  I now need to take some data, a NSString, convert it to hex, and then send it to the printer.  I tried several different ways, most of which from this site, but cannot get it to work.</p>
  
  <p>I know this doesn't work but I would like to do the following:</p>
  
  <pre><code>for(NSUInteger i = 0; i &lt; [str length]; i++ )
  {
      [hexString appendString:[NSString stringWithFormat:@"\x%@",[str characterAtIndex:i]]];
  }
  </code></pre>
  
  <ul>
  <li><ul>
  <li>hexString is the string I am trying to create and return.  str is the string I am trying turn into hex.  For example, 11111111 or abcdefg.</li>
  </ul></li>
  </ul>
  
  <p>I have tried a variety of things all with no luck.  </p>
  
  <p>Any help would be greatly appreciated!!!</p>