I'm writing a user personnal dictionary for ivrit
Usually, in ivrit, we don't write vowels. But for a dictionary, it is very important to save the word with vowels.
So, I need to display words with or without vowels. Of course, in the Database, I write words with vowels.
My question is: from a String containing vowels, how can I eliminate these vowels to display the word in a textfield without vowels
For instance: in ivrit the word "noise" is רַעַש the signs below the letters are the vowels.
so how can I write this word without vowels (רעש)?
I'm not an expert manipulating unicode, I've tried many things but I don't obtain the result I want
I'm not good at ivrit, but as far as I checked the code points of the word, vowels are represented by some compositiing characters.
let word = "רַעַש"
for ch in word.unicodeScalars {
print(String(format: "U+%04X", ch.value))
}U+05E8
U+05B7
U+05E2
U+05B7
U+05E9
There may be better ways, but you can write something like this.
let word = "רַעַש"
let points = CharacterSet(charactersIn:
"\u{5B0}\u{5B1}\u{5B2}\u{5B3}\u{5B4}\u{5B5}\u{5B6}\u{5B7}" +
"\u{5B8}\u{5B9}\u{5BA}\u{5BB}\u{5BC}\u{5BD}\u{5BF}" +
"\u{5C1}\u{5C2}"
)
let wordRemovingPoints = String(word.unicodeScalars.filter {!points.contains($0)})
print(wordRemovingPoints)You may need to modify the contents of `points`, please check the latest Unicode standard.