Skip to content

Instantly share code, notes, and snippets.

@saud978
Created June 14, 2022 07:42
Show Gist options
  • Save saud978/07095b28155a100773dd9b64e1c59646 to your computer and use it in GitHub Desktop.
Save saud978/07095b28155a100773dd9b64e1c59646 to your computer and use it in GitHub Desktop.
Convert numbers in string from Arabic to Hindi
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