I have some text formatting issues that I need to solve. I have some strange characters displaying from the NSString below
the original string:
NSString *descriptionStringPreFormatted = [item objectForKey:@"title"];
the formatted string:
NSString *descriptionLabelStringUTF8 = [descriptionStringPreFormatted stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"descriptionStringPreFormatted is %@", descriptionStringPreFormatted);
NSLog(@"descriptionLabelStringUTF8 is %@", descriptionLabelStringUTF8);
here’s the output which is the same whether I use the UTF8 encoding or not.
the output:
2013-01-05 16:44:51.807 descriptionStringPreFormatted is £144.99...
2013-01-05 16:44:51.810 descriptionLabelStringUTF8 is £144.99...
I think you are receiving dictionary “item” from web services. So try to decode that response string from webservice with NSUTF8StringEncoding.
NSString *str=[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
here “responseData” is raw data coming from web services.