It seems IsDigit and IsNumber in the unicode package don't behave differently, at least in my following test code:
package main
import "fmt"
import "unicode"
func main() {
r := rune('1')
fmt.Println(unicode.IsDigit(r))
fmt.Println(unicode.IsNumber(r))
//true
//true
}
They both print true
.
I tried to understand from their source code. However, I still don't understand what the differences are between them, even from their source code.
// IsNumber reports whether the rune is a number (category N).
func IsNumber(r rune) bool {
if uint32(r) <= MaxLatin1 {
return properties[uint8(r)]&pN != 0
}
return isExcludingLatin(Number, r)
}
// IsDigit reports whether the rune is a decimal digit.
func IsDigit(r rune) bool {
if r <= MaxLatin1 {
return '0' <= r && r <= '9'
}
return isExcludingLatin(Digit, r)
}