title: NSString from NSData -- Server returns NSData with leading nulls
body: <p>I haven't seen a very clear answer on this one. For some reason I don't understand, the server I am receiving data from returns a JSON response with a lot (hundreds, maybe) of null bytes at the beginning. </p>
  
  <p>When I use the following code, the string appears to be null:</p>
  
  <pre><code>    NSString* newStr = [[[NSString alloc] initWithData:dataToBeLoaded encoding:NSUTF8StringEncoding] autorelease];
  </code></pre>
  
  <p>This is apparently a common problem, but I haven't seen a clear answer on how to convert the NSData to an NSString.</p>
  
  <p>Up until recently, I saw this problem with an intermediate NSString value, but it went away after I stripped a handful (but not hundreds) of characters off of the beginning and end. The NSString after stripping was perfectly fine, so I suppose the encoding method was not the problem.</p>
  
  <p>Is there a built-in method that will do this properly? I have to imaging it would be more efficient that code I would write to go through byte-by-byte.</p>
  
  <p>By the way, when I manually send the JSON request to the server in my browser, the response comes back as perfectly valid JSON, with no obvious problems showing up in the browser screen.</p>
  
  <p>Any ideas what I should do? Thanks.</p>