Documentation
¶
Overview ¶
Package unicode gives SQLite case rules for every script, where SQLite's own upper, lower and NOCASE know only ASCII:
sqlite.NewConnector(dsn, unicode.Option())
Then:
unicode_upper(x) x in upper case, each character on its own as
Go's unicode.ToUpper: 'straße' gives 'STRAßE'
unicode_lower(x) x in lower case, each character on its own
x COLLATE unicode_nocase
compares as if both were case folded: 'Ä' = 'ä',
'Σ' = 'σ' = 'ς', 'K' (Kelvin sign) = 'k'
They have names of their own so that an index made with SQLite's upper, lower or NOCASE keeps the order it was made in. NULL gives NULL, a REAL is refused (write CAST(x AS TEXT)), and bytes that are not UTF-8 are kept as they are.
unicode_nocase orders ASCII as NOCASE does, and the other characters by the smallest code point they fold with. The folding comes from the Unicode tables of the Go that built the program, and a new Unicode can add a character that changes the order of old ones (U+037F joined U+03F3 in Unicode 7.0). After moving to a Go with a newer Unicode (unicode.Version), run REINDEX unicode_nocase on databases with indexes that use it.
Example ¶
package main
import (
"database/sql"
"fmt"
"github.com/liustack/sqlite"
"github.com/liustack/sqlite/ext/unicode"
)
func main() {
c, err := sqlite.NewConnector(":memory:", unicode.Option())
if err != nil {
panic(err)
}
db := sql.OpenDB(c)
defer db.Close()
var upper string
var same bool
err = db.QueryRow(`SELECT unicode_upper('größe'), 'ÉCOLE' = 'école' COLLATE unicode_nocase`).Scan(&upper, &same)
if err != nil {
panic(err)
}
fmt.Println(upper, same)
}
Output: GRÖßE true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.