Skip to content
Merged
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
26 changes: 16 additions & 10 deletions .tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,35 @@
"unicode_version": "13.0.0",
"cldr_version": "32",
"case_fold_hash": "3ab0454d1a85064a4c401b9a0c7162bd08a306ebd0dc34065b25701e6d38dba9",
"gen_go_hash": "3c10a98fa2bf15161cfaf5db1abba335476a0583661c37ea204bddef6d61cba0",
"gen_go_hash": "603931ec54064e5bf46593d31672b552c4698d5bef01aefb5da507543e506ca2",
"table_hashes": {
"CaseFolds": 2422855,
"FoldMap": 2521300993,
"UpperLower": 1793588629,
"_CaseFolds": 2422855,
"_FoldMap": 2521300993,
"_UpperLower": 1793588629
"UpperLower": 1793588629
}
},
"tables_go121.go": {
"filename": "tables_go121.go",
"unicode_version": "15.0.0",
"cldr_version": "32",
"case_fold_hash": "26ed8b8eee3e8fb11d5bc828b898e9b714fed8d34dea08089dde133d0b10fb04",
"gen_go_hash": "3c10a98fa2bf15161cfaf5db1abba335476a0583661c37ea204bddef6d61cba0",
"gen_go_hash": "603931ec54064e5bf46593d31672b552c4698d5bef01aefb5da507543e506ca2",
"table_hashes": {
"CaseFolds": 4292873350,
"FoldMap": 2521300993,
"UpperLower": 1793588629,
"_CaseFolds": 4292873350,
"_FoldMap": 4263480156,
"_UpperLower": 4290248538
"UpperLower": 1793588629
}
},
"tables_go127.go": {
"filename": "tables_go127.go",
"unicode_version": "17.0.0",
"cldr_version": "32",
"case_fold_hash": "dc6cc7a02620578ced5f7cff096043d463046a068304443aba325dfc5b3e3f03",
"gen_go_hash": "603931ec54064e5bf46593d31672b552c4698d5bef01aefb5da507543e506ca2",
"table_hashes": {
"CaseFolds": 4292873350,
"FoldMap": 935790141,
"UpperLower": 1333264157
}
}
}
2 changes: 1 addition & 1 deletion gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func realMain(args []string) int {
var exitcode int
// Supporting Unicode version 12.0.0 is annoying since arm64 support
// is lacking on Go 1.15 and below.
for _, version := range []string{"13.0.0", "15.0.0"} {
for _, version := range []string{"13.0.0", "15.0.0", "17.0.0"} {
code := genCmd(append([]string{"-unicode", version}, args...)...)
if exitcode == 0 {
exitcode = code
Expand Down
3 changes: 2 additions & 1 deletion internal/gen/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ var tags = []struct{ version, buildTags string }{
{"11.0.0", "go1.13,!go1.14"},
{"12.0.0", "go1.14,!go1.16"},
{"13.0.0", "go1.16"},
{"15.0.0", "go1.21"},
{"15.0.0", "go1.21,!go1.27"},
{"17.0.0", "go1.27"},
}

// buildTags reports the build tags used for the current Unicode version.
Expand Down
38 changes: 31 additions & 7 deletions internal/gen/gentables/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ func loadCaseFolds() {

var buildTags = map[string]struct{ version, buildTags, filename string }{
"13.0.0": {"13.0.0", "go1.16,!go1.21", "tables_go116.go"},
"15.0.0": {"15.0.0", "go1.21", "tables_go121.go"},
"15.0.0": {"15.0.0", "go1.21,!go1.27", "tables_go121.go"},
"17.0.0": {"17.0.0", "go1.27", "tables_go127.go"},
}

// tablesFileName is the names of the file to generate and is based off
Expand Down Expand Up @@ -753,10 +754,16 @@ func genFoldTable(w *bytes.Buffer, firstValidHash bool) {
runes := make(map[rune][]rune)
rangetable.Visit(categories, func(r rune) {
ff := folds(r)
if len(ff) > 2 {
runes[r] = append(runes[r], ff...)
}
if len(ff) == 1 && toUpper(r) != toLower(r) {
switch n := len(ff); {
case n > 2:
fallthrough
case n == 2 && ff[1] != toUpper(r) && ff[1] != toLower(r):
// A two-element fold orbit is normally covered by the _UpperLower
// table, but when the other rune is neither the upper nor lower
// case form of r it cannot be represented there and must be
// stored in _FoldMap.
fallthrough
case n == 1 && toUpper(r) != toLower(r):
runes[r] = append(runes[r], ff...)
}
})
Expand Down Expand Up @@ -1267,6 +1274,9 @@ var category = map[string]bool{
"S": true, // Sm Sc Sk So
"Z": true, // Zs Zl Zp
"C": true, // Cc Cf Cs Co Cn
// Multi-letter group categories added in go1.27.
"LC": true, // Lu Ll Lt (Cased_Letter)
"Cn": true, // Unassigned code points
}

// This contains only the properties we're interested in.
Expand Down Expand Up @@ -1363,10 +1373,24 @@ func loadCategoryTables() map[string]*unicode.RangeTable {
if _, ok := category[name]; !ok {
log.Fatal("unknown category", name)
}
// Previously, we only distinguished between "unified" and all other
// categories. Since go1.27, we need to also handle the "LC" (cased
// letter) and "Cn" (unassigned) categories. This code does that.
var rt *unicode.RangeTable
if len(name) == 1 { // unified categories
switch {
case name == "LC": // cased letter
rt = dumpRange(func(code rune) bool {
switch chars[code].category {
case "Lu", "Ll", "Lt":
return true
}
return false
})
case name == "Cn": // unassigned: no general category
rt = dumpRange(func(code rune) bool { return chars[code].category == "" })
case len(name) == 1: // unified categories
rt = dumpRange(func(code rune) bool { return categoryOp(code, name[0]) })
} else {
default:
rt = dumpRange(func(code rune) bool { return chars[code].category == name })
}
cats[name] = rt
Expand Down
2 changes: 1 addition & 1 deletion internal/tables/assigned/tables15.0.0.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading