x/text/collate: Key and KeyFromString silently ignore the collate.Force option #68379
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go version go1.22.5 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Attempted to sort strings using x/text/collate's collate.Force option, which implements deterministic comparison per Unicode TR10 (https://www.unicode.org/reports/tr10/#Forcing_Deterministic_Comparisons). Specifically, it forces strings to only compare as equal if they are bit-identical. Strings that are equivalent but not bit-equal are forced into a total order by using bytewise comparison of the raw byte sequence as a tie-breaker.
What did you see happen?
Key and KeyFromString ignore collate.Force, and return 0 (a == b) for strings that are equivalent but not bit-identical. Demo: https://go.dev/play/p/s_fwVG8pBD5 compares "Québécois" in normalization forms C and D (equivalent but different character sequences), and gets:
What did you expect to see?
All public APIs of Collator that are specified to compare things should be obeying the provided collation settings, or at least failing loud rather than silently producing a different collation order.
The text was updated successfully, but these errors were encountered: