Go has the unicode
package, containing useful functions such as IsGraphic
or IsPrint
. One function that is missing though is IsAssigned
. Of course I could write my own function by using the other functions. But I would rather expect the standard library to provide this function. In Java, writing this function is easy:
boolean isAssigned(int codePoint) {
return Character.getType(codePoint) != Character.UNASSIGNED;
}
In Go there is no function unicode.Type(rune)
or unicode.IsAssigned(rune)
. The closest I could find is this:
func IsAssigned(r rune) bool {
return unicode.IsControl(r) ||
unicode.IsGraphic(r) ||
unicode.IsSymbol(r)
}
But that code thinks that U+00AD (soft-hyphen) is unassigned, which is wrong.
How can I get correct information about unassigned code points?