Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/unicode/graphic.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func IsGraphic(r rune) bool {
if uint32(r) <= MaxLatin1 {
return properties[uint8(r)]&pg != 0
}
if Is(Variation_Selector, r) {
return false
}
return In(r, GraphicRanges...)
}

Expand All @@ -51,6 +54,9 @@ func IsPrint(r rune) bool {
if uint32(r) <= MaxLatin1 {
return properties[uint8(r)]&pp != 0
}
if Is(Variation_Selector, r) {
return false
}
return In(r, PrintRanges...)
}

Expand Down
44 changes: 44 additions & 0 deletions src/unicode/graphic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,50 @@ func TestIsPunctLatin1(t *testing.T) {
}
}

func TestIsGraphicVariationSelector(t *testing.T) {
// Variation selectors are invisible and should return false for IsGraphic.
for _, r16 := range Variation_Selector.R16 {
for r := rune(r16.Lo); r <= rune(r16.Hi); r += rune(r16.Stride) {
got := IsGraphic(r)
want := false
if got != want {
t.Errorf("%U incorrect: got %t; want %t", r, got, want)
}
}
}
for _, r32 := range Variation_Selector.R32 {
for r := rune(r32.Lo); r <= rune(r32.Hi); r += rune(r32.Stride) {
got := IsGraphic(r)
want := false
if got != want {
t.Errorf("%U incorrect: got %t; want %t", r, got, want)
}
}
}
}

func TestIsPrintVariationSelector(t *testing.T) {
// Variation selectors are invisible and should return false for IsPrint.
for _, r16 := range Variation_Selector.R16 {
for r := rune(r16.Lo); r <= rune(r16.Hi); r += rune(r16.Stride) {
got := IsPrint(r)
want := false
if got != want {
t.Errorf("%U incorrect: got %t; want %t", r, got, want)
}
}
}
for _, r32 := range Variation_Selector.R32 {
for r := rune(r32.Lo); r <= rune(r32.Hi); r += rune(r32.Stride) {
got := IsPrint(r)
want := false
if got != want {
t.Errorf("%U incorrect: got %t; want %t", r, got, want)
}
}
}
}

func TestIsSpaceLatin1(t *testing.T) {
for i := rune(0); i <= MaxLatin1; i++ {
got := IsSpace(i)
Expand Down