title: Creating a safe filename from an NSString?
body: <p>Is there way to take a NSString and turn it into a safe version that can be used as a filename to save to the user Documents directory on the iPhone.</p>
  
  <p>I'm currently doing something like this:</p>
  
  <pre><code>NSString *inputString = @"This is sample text which may have funny chars and spaces in.";
  
  NSInteger len = [inputString length];        
  NSString *newFilename = [[inputString substringToIndex:MIN(20, len)] stringByAppendingPathExtension:@"txt"];
  </code></pre>
  
  <p>This currently leaves me with something like:</p>
  
  <pre><code>This is sample text .txt
  </code></pre>
  
  <p>Need to make sure characters that are not allowed in filenames and stripped out too.</p>