// GetCharset returns the current numerical values of the per-session character
// set variables.
7325
func GetCharset(conn *Conn) (*binlogdatapb.Charset, error) {
	// character_set_client
	row, err := ExecuteFetchMap(conn, "SHOW COLLATION WHERE `charset`=@@session.character_set_client AND `default`='Yes'")
	if err != nil {
		return nil, err
	}
	client, err := strconv.ParseInt(row["Id"], 10, 16)
	if err != nil {
		return nil, err
	}

	// collation_connection
	row, err = ExecuteFetchMap(conn, "SHOW COLLATION WHERE `collation`=@@session.collation_connection")
	if err != nil {
		return nil, err
	}
	connection, err := strconv.ParseInt(row["Id"], 10, 16)
	if err != nil {
		return nil, err
	}

	// collation_server
	row, err = ExecuteFetchMap(conn, "SHOW COLLATION WHERE `collation`=@@session.collation_server")
	if err != nil {
		return nil, err
	}
	server, err := strconv.ParseInt(row["Id"], 10, 16)
	if err != nil {
		return nil, err
	}

	return &binlogdatapb.Charset{
		Client: int32(client),
		Conn:   int32(connection),
		Server: int32(server),
	}, nil
}
1308272
func GetAllCharsets() []*Desc {
	descs := make([]*Desc, 0, len(charsets))
	// The charsetInfos is an array, so the iterate order will be stable.
	for _, ci := range charsetInfos {
		c, ok := charsets[ci.Name]
		if !ok {
			continue
		}
		desc := &Desc{
			Name:             c.Name,
			DefaultCollation: c.DefaultCollation.Name,
			Desc:             c.Desc,
			Maxlen:           c.Maxlen,
		}
		descs = append(descs, desc)
	}
	return descs
}
1232388
func (s *Session) GetString(key string) string {
	r, _ := s.Get(key).(string)
	return r
}
1338447
public String getCharset(String defaultCharset)
	{
		Parameter charsetParam = param(PARAM_CHARSET);
		return charsetParam == null || charsetParam.value.length() == 0 ? defaultCharset : charsetParam.value;
	}
956534
func (pg *GoEvtxMap) GetUint(path *GoEvtxPath) (uint64, error) {
	s, err := pg.GetString(path)
	if err != nil {
		return 0, &ErrEvtxEltNotFound{*path}
	}
	u, err := strconv.ParseUint(s, 10, 64)
	if err != nil {
		return 0, err
	}
	return u, nil
}
1141043
func Get(charset int) *Converter {
	conv, ok := converters[charset]
	if !ok {
		return nil
	}
	return conv
}
407179
func (i *ASCIIArt) GetWidth() int {
	// Find the longest line
	var ret int
	for j := range i.contents {
		if len(i.contents[j]) > ret {
			ret = len(i.contents[j])
		}
	}
	return ret
}
462163
func GetString(key string) (string, error) {
	value, err := Get(key)
	if err != nil {
		return "", err
	}
	switch v := value.(type) {
	case int:
		return strconv.Itoa(v), nil
	case int64:
		return strconv.FormatInt(v, 10), nil
	case string:
		return v, nil
	}
	return "", &InvalidValue{key, "string|int|int64"}
}
690968
func ContentCharset(charsets ...string) http.HandlerFunc {
	for i, c := range charsets {
		charsets[i] = strings.ToLower(c)
	}
	return func(w http.ResponseWriter, r *http.Request) {
		if contentMethod(r.Method) && !checkCC(r.Header.Get("Content-Type"), charsets...) {
			w.WriteHeader(http.StatusUnsupportedMediaType)
		}
	}
}
1244577
func ResolveCharsetCollation(tblCharset, dbCharset string) (string, string, error) {
	if len(tblCharset) != 0 {
		defCollate, err := charset.GetDefaultCollation(tblCharset)
		if err != nil {
			// return terror is better.
			return "", "", ErrUnknownCharacterSet.GenWithStackByArgs(tblCharset)
		}
		return tblCharset, defCollate, nil
	}

	if len(dbCharset) != 0 {
		defCollate, err := charset.GetDefaultCollation(dbCharset)
		if err != nil {
			return "", "", ErrUnknownCharacterSet.GenWithStackByArgs(dbCharset)
		}
		return dbCharset, defCollate, errors.Trace(err)
	}

	charset, collate := charset.GetDefaultCharsetAndCollate()
	return charset, collate, nil
}
407813
func (list *List) GetString(idx int) (string, error) {
	value, err := list.Get(idx)
	if err != nil {
		return "", err
	}

	switch value.(type) {
	case *Primative:
		return value.(*Primative).AsString()
	}

	return "", errors.New("could not convert non-primative value to string")
}
1058264
func WithCharset(charset string) Configurator {
	return func(app *Application) {
		app.config.Charset = charset
	}
}
359981
func (ctx *Context) AcceptCharset(preferred ...string) string {
	return negotiator.New(ctx.Req.Header).Charset(preferred...)
}
377217
func ConvertCharsetCollateToLowerCaseIfNeed(tbInfo *model.TableInfo) {
	if tbInfo.Version >= model.TableInfoVersion3 {
		return
	}
	tbInfo.Charset = strings.ToLower(tbInfo.Charset)
	tbInfo.Collate = strings.ToLower(tbInfo.Collate)
	for _, col := range tbInfo.Columns {
		col.Charset = strings.ToLower(col.Charset)
		col.Collate = strings.ToLower(col.Collate)
	}
}
488292
func (engine *Engine) Charset(charset string) *Session {
	session := engine.NewSession()
	session.IsAutoClose = true
	return session.Charset(charset)
}
210155
func getCharsetAndCollateInTableOption(startIdx int, options []*ast.TableOption) (ca, co string, err error) {
	charsets := make([]string, 0, len(options))
	collates := make([]string, 0, len(options))
	for i := startIdx; i < len(options); i++ {
		opt := options[i]
		// we set the charset to the last option. example: alter table t charset latin1 charset utf8 collate utf8_bin;
		// the charset will be utf8, collate will be utf8_bin
		switch opt.Tp {
		case ast.TableOptionCharset:
			charsets = append(charsets, opt.StrValue)
		case ast.TableOptionCollate:
			collates = append(collates, opt.StrValue)
		}
	}

	if len(charsets) > 1 {
		return "", "", ErrConflictingDeclarations.GenWithStackByArgs(charsets[0], charsets[1])
	}
	if len(charsets) == 1 {
		if charsets[0] == "" {
			return "", "", ErrUnknownCharacterSet.GenWithStackByArgs("")
		}
		ca = charsets[0]
	}
	if len(collates) != 0 {
		for i := range collates {
			if collates[i] == "" {
				return "", "", ErrUnknownCollation.GenWithStackByArgs("")
			}
			if len(ca) != 0 && !charset.ValidCharsetAndCollation(ca, collates[i]) {
				return "", "", ErrCollationCharsetMismatch.GenWithStackByArgs(collates[i], ca)
			}
		}
		co = collates[len(collates)-1]
	}
	return
}
396997
func (rgc *RasterGraphicContext) GetStringBounds(s string) (left, top, right, bottom float64, err error) {
	f := rgc.GetFont()
	if f == nil {
		err = errors.New("No font loaded, cannot continue")
		return
	}
	rgc.recalc()

	left = math.MaxFloat64
	top = math.MaxFloat64

	cursor := 0.0
	prev, hasPrev := truetype.Index(0), false
	for _, rc := range s {
		index := f.Index(rc)
		if hasPrev {
			cursor += fUnitsToFloat64(f.Kern(fixed.Int26_6(rgc.current.Scale), prev, index))
		}

		if err = rgc.glyphBuf.Load(rgc.current.Font, fixed.Int26_6(rgc.current.Scale), index, font.HintingNone); err != nil {
			return
		}
		e0 := 0
		for _, e1 := range rgc.glyphBuf.Ends {
			ps := rgc.glyphBuf.Points[e0:e1]
			for _, p := range ps {
				x, y := pointToF64Point(p)
				top = math.Min(top, y)
				bottom = math.Max(bottom, y)
				left = math.Min(left, x+cursor)
				right = math.Max(right, x+cursor)
			}
			e0 = e1
		}
		cursor += fUnitsToFloat64(f.HMetric(fixed.Int26_6(rgc.current.Scale), index).AdvanceWidth)
		prev, hasPrev = index, true
	}
	return
}