Thursday, 18 April 2013

Convert some Special character to the Unicode/UTF 8 character and also Unicode to NSString....


    NSString *string = @"Hello & How % Are You?";
string = [string stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
string = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
string = [string stringByReplacingOccurrencesOfString:@"&" withString:@"%26"];
    NSLog(@"\n\n ===>> Before ==>> %@",string);
    
    NSString *string2 = string;
string2 = [string2 stringByReplacingOccurrencesOfString:@"%20" withString:@" "];
string2 = [string2 stringByReplacingOccurrencesOfString:@"%26" withString:@"&"];
string2 = [string2 stringByReplacingOccurrencesOfString:@"%25" withString:@"%"];    
    NSLog(@"\n\n ===>> After ==>> %@",string2);

Here you get out put is:

===>> Before ==>> Hello%20%25%20How%20Are%20You?
====>> After ==>> Hello % How Are You?

See My answer from this link.. http://stackoverflow.com/questions/16081390/how-to-get-from-web-service-in-iphone/16081968#16081968

And also list of Unicode/UTF 8 Character Table.. http://www.utf8-chartable.de/

1 comment:

  1. Hi ..

    I want to work application ios Exchange for a sum of money

    If you want to please communicate with me

    Thanks you ..

    E-mail : akq7@hotmail.com

    ReplyDelete