title: UTF8 Decoding with NSString
body: <p>I am new to Objective-C and try to convert a malformed UTF8 encoded NSString to a wellformed one using the example on <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/CreatingStrings.html" rel="nofollow">apples docs</a>.</p>
  
  <pre><code>NSString *theString = @"LÃ¼gen"; //should be "ü"
  NSString *asciiString = [[NSString alloc] initWithData:asciiData encoding:NSASCIIStringEncoding];
  
  NSLog(@"Original: %@ (length %d)", theString, [theString length]);  
  NSLog(@"Converted: %@ (length %d)", asciiString, [asciiString length]);
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>Original: LÃ¼gen (length 6)
  Converted: LA1/4gen (length 8)
  </code></pre>
  
  <p>This here is doing nothing:</p>
  
  <pre><code>NSString* str = [NSString stringWithUTF8String:
                   [theString cStringUsingEncoding:NSASCIIStringEncoding]];
  </code></pre>
  
  <p>This here crashes my app</p>
  
  <pre><code>NSString* str = [NSString stringWithUTF8String:
                   [theString cStringUsingEncoding:NSUTF8StringEncoding]];
  </code></pre>
  
  <p>Anyone any idea what I am doing wrong?</p>