parser: github.com/pingcap/parser/charset Index | Files

package charset

import "github.com/pingcap/parser/charset"

Index

Package Files

charset.go encoding_table.go

Constants

const (
    // CharsetBin is used for marking binary charset.
    CharsetBin = "binary"
    // CollationBin is the default collation for CharsetBin.
    CollationBin = "binary"
    // CharsetUTF8 is the default charset for string types.
    CharsetUTF8 = "utf8"
    // CollationUTF8 is the default collation for CharsetUTF8.
    CollationUTF8 = "utf8_bin"
    // CharsetUTF8MB4 represents 4 bytes utf8, which works the same way as utf8 in Go.
    CharsetUTF8MB4 = "utf8mb4"
    // CollationUTF8MB4 is the default collation for CharsetUTF8MB4.
    CollationUTF8MB4 = "utf8mb4_bin"
    // CharsetASCII is a subset of UTF8.
    CharsetASCII = "ascii"
    // CollationASCII is the default collation for CharsetACSII.
    CollationASCII = "ascii_bin"
    // CharsetLatin1 is a single byte charset.
    CharsetLatin1 = "latin1"
    // CollationLatin1 is the default collation for CharsetLatin1.
    CollationLatin1 = "latin1_bin"
)

Variables

var (
    ErrUnknownCollation         = terror.ClassDDL.New(mysql.ErrUnknownCollation, mysql.MySQLErrName[mysql.ErrUnknownCollation])
    ErrCollationCharsetMismatch = terror.ClassDDL.New(mysql.ErrCollationCharsetMismatch, mysql.MySQLErrName[mysql.ErrCollationCharsetMismatch])
)

func GetCharsetInfo Uses

func GetCharsetInfo(cs string) (string, string, error)

GetCharsetInfo returns charset and collation for cs as name.

func GetCharsetInfoByID Uses

func GetCharsetInfoByID(coID int) (string, string, error)

GetCharsetInfoByID returns charset and collation for id as cs_number.

func GetDefaultCharsetAndCollate Uses

func GetDefaultCharsetAndCollate() (string, string)

GetDefaultCharsetAndCollate returns the default charset and collation.

func GetDefaultCollation Uses

func GetDefaultCollation(charset string) (string, error)

GetDefaultCollation returns the default collation for charset.

func Lookup Uses

func Lookup(label string) (e encoding.Encoding, name string)

Lookup returns the encoding with the specified label, and its canonical name. It returns nil and the empty string if label is not one of the standard encodings for HTML. Matching is case-insensitive and ignores leading and trailing whitespace.

func ValidCharsetAndCollation Uses

func ValidCharsetAndCollation(cs string, co string) bool

ValidCharsetAndCollation checks the charset and the collation validity and returns a boolean.

type Charset Uses

type Charset struct {
    Name             string
    DefaultCollation string
    Collations       map[string]*Collation
    Desc             string
    Maxlen           int
}

Charset is a charset. Now we only support MySQL.

type Collation Uses

type Collation struct {
    ID          int
    CharsetName string
    Name        string
    IsDefault   bool
}

Collation is a collation. Now we only support MySQL.

func GetCollationByName Uses

func GetCollationByName(name string) (*Collation, error)

func GetCollations Uses

func GetCollations() []*Collation

GetCollations returns a list for all collations.

func GetSupportedCollations Uses

func GetSupportedCollations() []*Collation

GetSupportedCollations gets information for all collations supported so far.

type Desc Uses

type Desc struct {
    Name             string
    Desc             string
    DefaultCollation string
    Maxlen           int
}

Desc is a charset description.

func GetCharsetDesc Uses

func GetCharsetDesc(cs string) (*Desc, error)

GetCharsetDesc gets charset descriptions in the local charsets.

func GetSupportedCharsets Uses

func GetSupportedCharsets() []*Desc

GetSupportedCharsets gets descriptions for all charsets supported so far.

Package charset imports 11 packages (graph) and is imported by 133 packages. Updated 2020-02-08. Refresh now. Tools for package owners.