Encode and Decode using UTF-8 in iphone

Posted by Ekra on Stack Overflow See other posts from Stack Overflow or by Ekra
Published on 2011-01-13T13:09:17Z Indexed on 2011/01/16 4:53 UTC
Read the original article Hit count: 450

Hi friends,

I wanted an example were in I can encode and then decode the same string using UTF-8. Encode and then Decode means I want to implement the method in 2 area were one can encode it and other is able to decode it.

I have seen the API but I didnt get much success:-

StringWithCString:encoding:

stringWithUTF8String:

stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc;

=================EDITED=================

I have string as "øæ-test-2.txt" .

when I am encoding it

char *s = "øæ-test-2.txt";

NSString *enc = [NSString stringWithCString:s encoding:NSASCIIStringEncoding];

I am getting

"øæ-test-2.txt" as output.

Now I want to get back the original string back i.e. "øæ-test-2.txt"

+++++++++EDITED+++++++++++++++++++

I am getting "øæ-test-2.txt" from server and I need "øæ-test-2.txt" by decoding it . I am able to get the output from the link below

http://www.cafewebmaster.com/online_tools/utf_decode

Please try to use the link and u will understand my concern.

I need the solution on urgent basis.

It would be highly appreciated if anyone can give some hint or tutorial in right direction.

Regards

© Stack Overflow or respective owner

Related posts about iphone

Related posts about encoding