Given a string var word that represents a word, and a string var letter that represents a letter, how do I count the number of accented letters in the word?
If var letter is a non-accented word, my code works, but when the letter is accented or any special character, var counter prints the number 0.
package main
import "fmt"
func main() {
word := "cèòài"
letter := "è"
var counter int
for i := 0; i < len(word); i++ {
if string(word[i]) == letter {
counter++
}
}
fmt.Print(counter)
}
I imagine this error is due to some encoding problem but can't quite grasp what I need to look into.