Md.Ashik Mahmud
Md.Ashik Mahmud

Reputation: 49

How I convert numerical digit to bengali digit in Objective-C?

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

Answers (1)

Adam
Adam

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

Related Questions