Skip to content

Instantly share code, notes, and snippets.

@JKalash
Last active March 8, 2017 09:00
Show Gist options
  • Save JKalash/0fd11feed6e8d5ddf992c58d334ce071 to your computer and use it in GitHub Desktop.
Save JKalash/0fd11feed6e8d5ddf992c58d334ce071 to your computer and use it in GitHub Desktop.
Swift 3 extension to the UnicodeScalar struct holding an isArabic property
extension UnicodeScalar {
var isArabic : Bool {
switch value {
case 0x0600 ... 0x06FF, //Arabic 255 characters
0x0750 ... 0x077F, //Arabic Supplement 48 characters
0x08A0 ... 0x08FF, //Arabic Extended-A 73 characters
0xFB50 ... 0xFDFF, //Arabic Presentation Forms-A 611 characters
0xFE70 ... 0xFEFF, //Arabic Presentation Forms-B 141 characters
0x10E60 ... 0x10E7F, //Rumi Numeral symbols 31 characters
0x1EE00 ... 0x1EEFF : return true //Arabic Mathematical Alphabetic Symbols 143 characters
default: return false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment