// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package rangetable provides utilities for creating and inspecting // unicode.RangeTables.
package rangetable import ( ) // New creates a RangeTable from the given runes, which may contain duplicates. func ( ...rune) *unicode.RangeTable { if len() == 0 { return &unicode.RangeTable{} } sort.Sort(byRune()) // Remove duplicates. := 1 for := 1; < len(); ++ { if [-1] != [] { [] = [] ++ } } var unicode.RangeTable for , := range [:] { if <= 0xFFFF { .R16 = append(.R16, unicode.Range16{Lo: uint16(), Hi: uint16(), Stride: 1}) } else { .R32 = append(.R32, unicode.Range32{Lo: uint32(), Hi: uint32(), Stride: 1}) } } // Optimize RangeTable. return Merge(&) } type byRune []rune func ( byRune) () int { return len() } func ( byRune) (, int) { [], [] = [], [] } func ( byRune) (, int) bool { return [] < [] } // Visit visits all runes in the given RangeTable in order, calling fn for each. func ( *unicode.RangeTable, func(rune)) { for , := range .R16 { for := rune(.Lo); <= rune(.Hi); += rune(.Stride) { () } } for , := range .R32 { for := rune(.Lo); <= rune(.Hi); += rune(.Stride) { () } } } // Assigned returns a RangeTable with all assigned code points for a given // Unicode version. This includes graphic, format, control, and private-use // characters. It returns nil if the data for the given version is not // available. func ( string) *unicode.RangeTable { return assigned[] }