Skip to content

fix: parse single-rune Unicode flags - #2434

Open
znnnnnnn-wil wants to merge 1 commit into
urfave:mainfrom
znnnnnnn-wil:fix/2433-unicode-flag-runes
Open

znnnnnnn-wil wants to merge 1 commit into
urfave:mainfrom
znnnnnnn-wil:fix/2433-unicode-flag-runes

Conversation

@znnnnnnn-wil

Copy link
Copy Markdown

What type of PR is this?

  • bug

What this PR does / why we need it:

  • Count Unicode code points, rather than UTF-8 bytes, when selecting the prefix for a flag name.
  • Decode the first rune after - before deciding whether an argument is a flag.
  • Add a regression test showing that a single-rune Hebrew flag is displayed and parsed like a single-character ASCII flag.

Some code and tests were assisted by Codex. I reviewed, understood, and tested the complete change and take responsibility for it.

Which issue(s) this PR fixes:

Fixes #2433

Special notes for your reviewer:

The parsing change only affects non-ASCII input. ASCII arguments decode to the same rune value as the byte previously inspected.

Testing

  • go test . -run '^TestCommand_SingleRuneUnicodeFlag$' -count=1
  • go test ./... -count=1
  • go run scripts/build.go vet
  • go run scripts/build.go check-binary-size
  • go run scripts/build.go generate
  • go run scripts/build.go gfmrun
  • Equivalent public API diff using git diff --no-index --ignore-all-space (no differences)

The repository's go run scripts/build.go test command requires -race; it could not run on this Windows host because CGO is disabled and no C compiler is installed. The same packages passed without -race, and CI will run the race-enabled suite on supported runners.

Release Notes

Fix parsing and help formatting for single-rune Unicode flag names.

Count Unicode code points when choosing a flag prefix and decode the first flag rune before classifying it as an option.

Fixes urfave#2433
@znnnnnnn-wil
znnnnnnn-wil requested a review from a team as a code owner September 19, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-rune Unicode flags can be emitted by completion but not parsed

1 participant