title: Encode and Decode using UTF-8 in iPhone
body: <p>I'm looking for an example demonstrating how I can encode and then decode the same string using UTF-8. Encode and then Decode means I want to implement the methods in 2 areas where one can encode it and another is able to decode it.</p>
  
  <p>I have seen the API but I didn't get much success:</p>
  
  <ul>
  <li><code>stringWithCString:encoding:</code></li>
  <li><code>stringWithUTF8String:</code></li>
  <li><code>stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc;</code></li>
  </ul>
  
  <hr>
  
  <p><strong>EDITED</strong><br>
  I have the string <code>øæ-test-2.txt</code> which I am encoding as follows: </p>
  
  <pre><code>char *s = "øæ-test-2.txt";
  NSString *enc = [NSString stringWithCString:s encoding:NSASCIIStringEncoding];
  </code></pre>
  
  <p>but am getting <code>Ã¸Ã¦-test-2.txt</code> as output.
  Now I want to get back the original string back i.e. <code>øæ-test-2.txt</code></p>
  
  <hr>
  
  <p><strong>EDITED</strong><br>
  I am getting <code>Ã¸Ã¦-test-2.txt</code>  from server and I need <code>øæ-test-2.txt</code> by decoding it. I am able to get the output from the link : <a href="http://www.cafewebmaster.com/online_tools/utf_decode" rel="nofollow">http://www.cafewebmaster.com/online_tools/utf_decode</a> </p>
  
  <p>Please try to use the link and you will understand my concern. </p>
  
  <p>It would be highly appreciated if anyone can give some hint, tutorial or point me in the right direction.</p>
  
  <p>Regards</p>