decomposedStringWithCompatibilityMapping
Returns a string made by normalizing the receiver’s contents using Form KD.
- (NSString *)decomposedStringWithCompatibilityMapping
Return Value of [NSString decomposedStringWithCompatibilityMapping]
A string made by normalizing the receiver’s contents using the Unicode Normalization Form KD.
Example of [NSString decomposedStringWithCompatibilityMapping]
NSString *str = @"aąbcčdeęėfghiįjzž";
NSLog(@"%@", str);
NSMutableString *s = [[str decomposedStringWithCompatibilityMapping] mutableCopy];
NSUInteger pos = 0;
while(pos < s.length) {
NSRange r = [s rangeOfComposedCharacterSequenceAtIndex:pos];
if (r.location == NSNotFound) break;
pos = ++r.location;
if (r.length == 1) continue;
r.length--;
[s deleteCharactersInRange:r];
}
NSLog(@"%@", s);
Example of [NSString decomposedStringWithCompatibilityMapping]
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);