[go] unicode: remove variation selectors from IsGraphic and IsPrint

3 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Dec 17, 2025, 9:06:30 PM (4 days ago) Dec 17
to goph...@pubsubhelper.golang.org, Saransh Saini, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

unicode: remove variation selectors from IsGraphic and IsPrint

IsGraphic and IsPrint return true for Variation Selectors, which are invisible. This just adds a check to not include those, and a test to verify.

Fixes #73673
Change-Id: Iaf324046e54207b04ddf88bf8f6219a09f961757
GitHub-Last-Rev: 4a18f5272cf36474b8e28a85794534a800fde407
GitHub-Pull-Request: golang/go#76875

Change diff

diff --git a/src/unicode/graphic.go b/src/unicode/graphic.go
index aa62f2a..f5c2773 100644
--- a/src/unicode/graphic.go
+++ b/src/unicode/graphic.go
@@ -39,6 +39,9 @@
if uint32(r) <= MaxLatin1 {
return properties[uint8(r)]&pg != 0
}
+ if Is(Variation_Selector, r) {
+ return false
+ }
return In(r, GraphicRanges...)
}

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

diff --git a/src/unicode/graphic_test.go b/src/unicode/graphic_test.go
index c9f289c..15167e6 100644
--- a/src/unicode/graphic_test.go
+++ b/src/unicode/graphic_test.go
@@ -101,6 +101,50 @@
}
}

+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)

Change information

Files:
  • M src/unicode/graphic.go
  • M src/unicode/graphic_test.go
Change size: M
Delta: 2 files changed, 50 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Iaf324046e54207b04ddf88bf8f6219a09f961757
Gerrit-Change-Number: 730980
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: Saransh Saini <sarans...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
Dec 17, 2025, 9:06:31 PM (4 days ago) Dec 17
to Saransh Saini, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Gopher Robot . unresolved

I spotted some possible problems with your PR:

  1. You have a long 146 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)
2. Do you have the right bug reference format? For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message.

Please address any problems by updating the GitHub PR.

When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

For more details, see:

(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Iaf324046e54207b04ddf88bf8f6219a09f961757
    Gerrit-Change-Number: 730980
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Saransh Saini <sarans...@google.com>
    Gerrit-Comment-Date: Thu, 18 Dec 2025 02:06:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    Dec 17, 2025, 9:09:10 PM (4 days ago) Dec 17
    to Saransh Saini, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Message from Gopher Robot

    Congratulations on opening your first change. Thank you for your contribution!

    Next steps:
    A maintainer will review your change and provide feedback. See
    https://go.dev/doc/contribute#review for more info and tips to get your
    patch through code review.

    Most changes in the Go project go through a few rounds of revision. This can be
    surprising to people new to the project. The careful, iterative review process
    is our way of helping mentor contributors and ensuring that their contributions
    have a lasting impact.

    During May-July and Nov-Jan the Go project is in a code freeze, during which
    little code gets reviewed or merged. If a reviewer responds with a comment like
    R=go1.11 or adds a tag like "wait-release", it means that this CL will be
    reviewed as part of the next development cycle. See https://go.dev/s/release
    for more details.

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Iaf324046e54207b04ddf88bf8f6219a09f961757
    Gerrit-Change-Number: 730980
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Saransh Saini <sarans...@google.com>
    Gerrit-Comment-Date: Thu, 18 Dec 2025 02:09:05 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gerrit Bot (Gerrit)

    unread,
    Dec 17, 2025, 9:15:06 PM (4 days ago) Dec 17
    to Saransh Saini, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Gerrit Bot uploaded new patchset

    Gerrit Bot uploaded patch set #2 to this change.
    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Iaf324046e54207b04ddf88bf8f6219a09f961757
    Gerrit-Change-Number: 730980
    Gerrit-PatchSet: 2
    unsatisfied_requirement
    open
    diffy

    Saransh Saini (Gerrit)

    unread,
    Dec 17, 2025, 9:21:20 PM (4 days ago) Dec 17
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

    Saransh Saini added 1 comment

    Patchset-level comments
    File-level comment, Patchset 1:
    Gopher Robot . resolved

    I spotted some possible problems with your PR:

      1. You have a long 146 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)
    2. Do you have the right bug reference format? For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message.

    Please address any problems by updating the GitHub PR.

    When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

    To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

    For more details, see:

    (In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

    Saransh Saini

    Done

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Iaf324046e54207b04ddf88bf8f6219a09f961757
      Gerrit-Change-Number: 730980
      Gerrit-PatchSet: 2
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Saransh Saini <sarans...@google.com>
      Gerrit-Comment-Date: Thu, 18 Dec 2025 02:21:16 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Gopher Robot <go...@golang.org>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Rob Pike (Gerrit)

      unread,
      Dec 19, 2025, 5:59:21 PM (2 days ago) Dec 19
      to Saransh Saini, Gerrit Bot, goph...@pubsubhelper.golang.org, Rob Pike, Marcel van Lohuizen, Gopher Robot, golang-co...@googlegroups.com

      Rob Pike added 1 comment

      File src/unicode/graphic.go
      Line 42, Patchset 2 (Latest): if Is(Variation_Selector, r) {
      Rob Pike . unresolved

      Can't pg (and pp below) be tweaked to do this? That feels like the right way to solve this.

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Iaf324046e54207b04ddf88bf8f6219a09f961757
        Gerrit-Change-Number: 730980
        Gerrit-PatchSet: 2
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Rob Pike <r...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Marcel van Lohuizen <mp...@golang.org>
        Gerrit-CC: Saransh Saini <sarans...@google.com>
        Gerrit-Comment-Date: Fri, 19 Dec 2025 22:59:10 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        open
        diffy

        Saransh Saini (Gerrit)

        unread,
        Dec 19, 2025, 6:39:58 PM (2 days ago) Dec 19
        to Gerrit Bot, goph...@pubsubhelper.golang.org, Rob Pike, Marcel van Lohuizen, Gopher Robot, golang-co...@googlegroups.com

        Saransh Saini added 1 comment

        File src/unicode/graphic.go
        Line 42, Patchset 2 (Latest): if Is(Variation_Selector, r) {
        Rob Pike . unresolved

        Can't pg (and pp below) be tweaked to do this? That feels like the right way to solve this.

        Saransh Saini

        It looks like pg is not entered for variation selectors because theyre out of the latin1 range. Is there a more elegant way to solve this you think other than this if check?

        Open in Gerrit

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: Iaf324046e54207b04ddf88bf8f6219a09f961757
        Gerrit-Change-Number: 730980
        Gerrit-PatchSet: 2
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Rob Pike <r...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Marcel van Lohuizen <mp...@golang.org>
        Gerrit-CC: Saransh Saini <sarans...@google.com>
        Gerrit-Comment-Date: Fri, 19 Dec 2025 23:39:52 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Rob Pike <r...@golang.org>
        unsatisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages