jeremie
jeremie

Reputation: 1131

Get unicode script from a rune in Go

In Unicode there are some existing defined range unicode range, I'm looking for something so that given a rune I can find its Unicode Script.

In the unicode package I found this function, but it doesn't seem to do what I want.

chineseChars := "人人"
for _, rune := range chineseChars {
    fmt.Println(unicode.In(rune, unicode.Bopomofo))
}

This piece of code prints false when it should print true

Upvotes: 0

Views: 98

Answers (1)

Thundercat
Thundercat

Reputation: 121129

The unicode package puts in Han, not Bopomofo. The expression unicode.In('人', unicode.Han) evaluates to true.

Upvotes: 1

Related Questions