I have an english string that may or may not have numbers. But i want those numbers to be printed on screen as Persian numbers.
For example if NSString *foo = @"a string with numbers 1 2 3;"
then output should be a string with numbers ۱۲۳
The code I'm using right now is :
-(NSString *)convertEnNumberToFarsi:(NSString *) number{
NSString *text;
NSDecimalNumber *someNumber = [NSDecimalNumber decimalNumberWithString:number];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
NSLocale *gbLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"fa"];
[formatter setLocale:gbLocale];
text = [formatter stringFromNumber:someNumber];
return text;
}
This method only converts a string that is only in numbers, but as mentioned above i want to convert any string that may or may not have numbers in it.
How can i achieve this?