279
// caseOrbit is defined in tables.go as []foldPair. Right now all the
280
// entries fit in uint16, so use uint16. If that changes, compilation
281
// will fail (the constants in the composite literal will not fit in uint16)
282
// and the types here can change to uint32.
283
type foldPair struct {
288
// SimpleFold iterates over Unicode code points equivalent under
289
// the Unicode-defined simple case folding. Among the code points
290
// equivalent to rune (including rune itself), SimpleFold returns the
291
// smallest r >= rune if one exists, or else the smallest r >= 0.
294
// SimpleFold('A') = 'a'
295
// SimpleFold('a') = 'A'
297
// SimpleFold('K') = 'k'
298
// SimpleFold('k') = '\u212A' (Kelvin symbol, K)
299
// SimpleFold('\u212A') = 'K'
301
// SimpleFold('1') = '1'
303
func SimpleFold(rune int) int {
304
// Consult caseOrbit table for special cases.
309
if int(caseOrbit[m].From) < rune {
315
if lo < len(caseOrbit) && int(caseOrbit[lo].From) == rune {
316
return int(caseOrbit[lo].To)
319
// No folding specified. This is a one- or two-element
320
// equivalence class containing rune and ToLower(rune)
321
// and ToUpper(rune) if they are different from rune.
322
if l := ToLower(rune); l != rune {