I would like to know if a string contains Russian/Cyrillic characters.
For latin characters, I do something like this (pseudocode):
text := "test"
for _, r := range []rune(text) {
if r >= 'a' && r <= 'z' {
return True
}
}
return False
What is the corresponding way to do it for Russian/Cyrillic alphabet?
This seems to work
unicode.Is(unicode.Cyrillic, r) // r is a rune
I went on and did this example implementation for finding russian uppercase chars, based on this Unicode chart:
func isRussianUpper(text string) bool {
for _, r := range []rune(text) {
if r < '\u0410' || r > '\u042F' {
return false
}
}
return true
}
You can do any set of characters this way. Just modify the codes of characters you are interested in.