Documentation ¶
Index ¶
- Constants
- Variables
- func AddCharset(c *Charset)
- func AddCollation(c *Collation)
- func FindNextCharacterLength(label string) func([]byte) int
- func GetCharsetInfoByID(coID int) (string, string, error)
- func GetDefaultCharsetAndCollate() (string, string)
- func GetDefaultCollation(charset string) (string, error)
- func GetDefaultCollationLegacy(charset string) (string, error)
- func Lookup(label string) (e encoding.Encoding, name string)
- func RemoveCharset(c string)
- func ValidCharsetAndCollation(cs string, co string) bool
- type Charset
- type Collation
- type Encoding
- type EncodingLabel
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" CollationGBKBin = "gbk_bin" CharsetARMSCII8 = "armscii8" CharsetBig5 = "big5" CharsetBinary = "binary" CharsetCP1250 = "cp1250" CharsetCP1251 = "cp1251" CharsetCP1256 = "cp1256" CharsetCP1257 = "cp1257" CharsetCP850 = "cp850" CharsetCP852 = "cp852" CharsetCP866 = "cp866" CharsetCP932 = "cp932" CharsetDEC8 = "dec8" CharsetEUCJPMS = "eucjpms" CharsetEUCKR = "euckr" CharsetGB18030 = "gb18030" CharsetGB2312 = "gb2312" CharsetGBK = "gbk" CharsetGEOSTD8 = "geostd8" CharsetGreek = "greek" CharsetHebrew = "hebrew" CharsetHP8 = "hp8" CharsetKEYBCS2 = "keybcs2" CharsetKOI8R = "koi8r" CharsetKOI8U = "koi8u" CharsetLatin2 = "latin2" CharsetLatin5 = "latin5" CharsetLatin7 = "latin7" CharsetMacCE = "macce" CharsetMacRoman = "macroman" CharsetSJIS = "sjis" CharsetSWE7 = "swe7" CharsetTIS620 = "tis620" CharsetUCS2 = "ucs2" CharsetUJIS = "ujis" CharsetUTF16 = "utf16" CharsetUTF16LE = "utf16le" CharsetUTF32 = "utf32" )
Variables ¶
var ( ErrUnknownCollation = terror.ClassDDL.NewStd(mysql.ErrUnknownCollation) ErrCollationCharsetMismatch = terror.ClassDDL.NewStd(mysql.ErrCollationCharsetMismatch) )
Functions ¶
func AddCharset ¶
func AddCharset(c *Charset)
AddCharset adds a new charset. Use only when adding a custom charset to the parser.
func AddCollation ¶
func AddCollation(c *Collation)
AddCollation adds a new collation. Use only when adding a custom collation to the parser.
func FindNextCharacterLength ¶
FindNextCharacterLength is used in lexer.peek() to determine the next character length.
func GetCharsetInfoByID ¶
GetCharsetInfoByID returns charset and collation for id as cs_number.
func GetDefaultCharsetAndCollate ¶
GetDefaultCharsetAndCollate returns the default charset and collation.
func GetDefaultCollation ¶
GetDefaultCollation returns the default collation for charset.
func GetDefaultCollationLegacy ¶
GetDefaultCollationLegacy is compatible with the charset support in old version parser.
func Lookup ¶
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 RemoveCharset ¶
func RemoveCharset(c string)
RemoveCharset remove a charset. Use only when adding a custom charset to the parser.
func ValidCharsetAndCollation ¶
ValidCharsetAndCollation checks the charset and the collation validity and returns a boolean.
Types ¶
type Charset ¶
type Charset struct { Name string DefaultCollation string Collations map[string]*Collation Desc string Maxlen int }
Charset is a charset. Now we only support MySQL.
func GetCharsetInfo ¶
GetCharsetInfo returns charset and collation for cs as name.
func GetSupportedCharsets ¶
func GetSupportedCharsets() []*Charset
GetSupportedCharsets gets descriptions for all charsets supported so far.
type Collation ¶
Collation is a collation. Now we only support MySQL.
func GetCollationByID ¶
GetCollationByID returns collations by given id.
func GetCollationByName ¶
func GetCollations ¶
func GetCollations() []*Collation
GetCollations returns a list for all collations.
func GetSupportedCollations ¶
func GetSupportedCollations() []*Collation
GetSupportedCollations gets information for all collations supported so far.
type Encoding ¶
type Encoding struct {
// contains filtered or unexported fields
}
Encoding provide a interface to encode/decode a string with specific encoding.
func (*Encoding) UpdateEncoding ¶
func (e *Encoding) UpdateEncoding(label EncodingLabel)
UpdateEncoding updates to a new Encoding.
type EncodingLabel ¶
type EncodingLabel string
func Format ¶
func Format(label string) EncodingLabel
Format trim and change the label to lowercase.
func Formatted ¶
func Formatted(label string) EncodingLabel
Formatted is used when the label is already trimmed and it is lowercase.