I have used web service and get the response in the XML format, after that i have used xml parsing for parsed contents, but i get ı: ürse kün 开发者_如何转开发etc., SO i want to remove that special characters and i have used NSUTF8StringEncoding and NSASCIIStringEncoding. But it doesn't work, so please give help me out?.
Either what you have is binary data, or you have a string in some encoding that's not UTF-8. Assuming it's the latter, you need to figure out what that encoding is, which is entirely dependent on the data, what it is, and where it came from.
TESTED CODE: 100 % WORKS
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"];
NSString *input = @"ı: ürse kün";
NSString *folded = [input stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:locale];
NSLog(@"resulted String is - %@",folded);
OUTPUT:
resulted String is - A±: A¼rse kA¼n
OR
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"];
NSString *input = @"ı: ürse kün vijay 12344";
input = [input decomposedStringWithCompatibilityMapping];
NSString *output=[input stringByTrimmingCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ0123456789"] invertedSet]];
NSString *folded = [output stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:locale];
NSLog(@"resulted String is :%@",folded);
OUTPUT:
resulted String is :A±: A1⁄4rse kA1⁄4n vijay 12344
精彩评论