You can use the CoreFoundation CFStringTransform function, which performs almost all the conversions from your list. Only "ฤ" and "ฤ" need to be processed separately:
NSString *UnicodeUnsign(NSString *s) { NSMutableString *result = [s mutableCopy]; // __bridge only required if you compile with ARC: CFStringTransform((__bridge CFMutableStringRef)result, NULL, kCFStringTransformStripCombiningMarks, NO); [result replaceOccurrencesOfString:@"ฤ" withString:@"d" options:0 range:NSMakeRange(0, [result length])]; [result replaceOccurrencesOfString:@"ฤ" withString:@"D" options:0 range:NSMakeRange(0, [result length])]; return result; }
Example:
NSString *input = @"Hแป
llรถ Wรตrld! - แบฟแปแป
แปฤรฌรญแปฤฉแปรฒรณ"; NSString *output = UnicodeUnsign(input); NSLog(@"%@", output);
source share