how to write ivrit words without vowels

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

Answered by OOPer in 380122022

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.

Accepted Answer

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.

The Hebrew vowels are considered to be diacriticals, and thus you can strip them like you would any diacritical:

let s = "רַעַש"
print(s)
print(s.applyingTransform(.stripDiacritics, reverse: false)!)

prints:

רַעַש
רעש

This only makes sense if you know you’re dealing with Hebrew. If you’re dealing with other languages, or mixed languages, stripping diacriticals is considered poor form. For example, Anders Jonas Ångström would be grumpy if you rendered his name Anders Jonas Angstrom because Å and ö are unique letters in Swedish.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

This work perfectly well

Thanks

Thank's this is great because veru concise

how to write ivrit words without vowels
 
 
Q