Reputation: 49
I need to convert numerical digit to bengali digit. if my input 12,then output ১২ . I am trying to start it using regular expression,
NSArray *digitArray=@[@"90", @"10", @"32"];
NSError *error;
NSString *pattern = @"^[0-9]*$";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern
options:NSRegularExpressionCaseInsensitive
error:&error];
But I don't understand which process I follow to implement the conversion.
Upvotes: 0
Views: 73
Reputation: 26917
You can use a number formatter with specific locale, like following:
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"bn_BD"];
NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init];
fmt.locale = locale;
NSString *bengaliString = [fmt stringFromNumber:@20];
Where @20
is a NSNumber
literal.
Upvotes: 1