Created
June 14, 2022 07:42
-
-
Save saud978/07095b28155a100773dd9b64e1c59646 to your computer and use it in GitHub Desktop.
Convert numbers in string from Arabic to Hindi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func convertToArbic () -> String? { | |
let formatter = NumberFormatter() | |
formatter.locale = Locale(identifier: "EN") | |
guard let number = formatter.number(from:self ) else{ | |
return nil | |
} | |
formatter.locale = Locale(identifier: "AR") | |
guard let number2 = formatter.string(from: number) else{ | |
return nil | |
} | |
return number2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment