This function searches how many times a character appears in a string:
let str = "الصَّبَاْحُ جَمِيْلٌ"
let char: Character = "َ"
func SpecificLetterCount(_ str:String, _ char:Character) -> Int {
let letters = Array(str); var count = 0
for letter in letters {
if letter == char {
count += 1
}
}
return count
}
print(SpecificLetterCount(str, char)) //Prints 0 , where in fact it should find it 3 times in that string!
In this case the result is 0 , where in fact it should find it 3 times in that string!, but because it is a non-spacing mark (a special character) it can't find it by itself. The same happens with this character: ( e + ́ ) = é , where I can't find ( ́ ) by itself!