summaryrefslogtreecommitdiff
path: root/src/pkg/unicode/graphic.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/unicode/graphic.go')
-rw-r--r--src/pkg/unicode/graphic.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/pkg/unicode/graphic.go b/src/pkg/unicode/graphic.go
index 5b995fcd0..ba90b4e51 100644
--- a/src/pkg/unicode/graphic.go
+++ b/src/pkg/unicode/graphic.go
@@ -39,7 +39,7 @@ func IsGraphic(r rune) bool {
if uint32(r) <= MaxLatin1 {
return properties[uint8(r)]&pg != 0
}
- return IsOneOf(GraphicRanges, r)
+ return In(r, GraphicRanges...)
}
// IsPrint reports whether the rune is defined as printable by Go. Such
@@ -51,12 +51,23 @@ func IsPrint(r rune) bool {
if uint32(r) <= MaxLatin1 {
return properties[uint8(r)]&pp != 0
}
- return IsOneOf(PrintRanges, r)
+ return In(r, PrintRanges...)
}
// IsOneOf reports whether the rune is a member of one of the ranges.
-func IsOneOf(set []*RangeTable, r rune) bool {
- for _, inside := range set {
+// The function "In" provides a nicer signature and should be used in preference to IsOneOf.
+func IsOneOf(ranges []*RangeTable, r rune) bool {
+ for _, inside := range ranges {
+ if Is(inside, r) {
+ return true
+ }
+ }
+ return false
+}
+
+// In reports whether the rune is a member of one of the ranges.
+func In(r rune, ranges ...*RangeTable) bool {
+ for _, inside := range ranges {
if Is(inside, r) {
return true
}