cocoa - How can I decode a utf8 NSstring on iphone? -


I have NSstring which is encoded with UTF 8. I want to decode it.

I tried to do this but it does not work:

  NSString * decodedString = [NSString stringWithUTF8 string: [Encoded string CStringUsingEncoding: [NSString defaultCStringEncoding]]];   

>

sending cStringUsingEncoding: to encoded string only if encoded string An NSString object is a means of having an NSString object which is the point you want to achieve, in that method, there is no decode string in it, using the encoding string encodes < / Em> does; In this way, in the code you show, you ask for the encoding (randomly encoded) in some random encoding (the default C string encoding), then decoding the result as UTF-8 Let's try. It will not work.

You do not specify what type of code you are using encodedString by any means, by passing you the encoded string and passing its encoding, the NSString object Need to create.

  • If encodedString is an NSData object, then use
  • if it is a redundant string;

initWithUTF8 string:

  • / Code> You need to specify the encoding ( initWithUTF8 string: by definition), and initWithData: encoding: except for an autoresaving feature version ( + StringWith ... Instead of -initWith ... ).


  • Comments

    Popular posts from this blog

    c# - How to capture HTTP packet with SharpPcap -

    php - Multiple Select with Explode: only returns the word "Array" -

    php - jQuery AJAX Post not working -