// Escape escapes the provided identifier based on the EscType.
165726
func (tl TypeLoader) Escape(typ EscType, s string) string {
	if e, ok := tl.Esc[typ]; ok && e != nil {
		return e(s)
	}

	return `"` + s + `"`
}
852125
func Encode(data interface{}) string {
	switch v := data.(type) {
	case string:
		return EncodeString(v)
	case int:
		return EncodeInt(v)
	case []interface{}:
		return EncodeList(v)
	case map[string]interface{}:
		return EncodeDict(v)
	default:
		panic("invalid type when encode")
	}
}
857762
func EscapeAssertion(s string) string {
	//Replace the first dot, because it can't be recognized by the regexp.
	if (strings.HasPrefix(s, "r") || strings.HasPrefix(s, "p")) {
		s = strings.Replace(s, ".", "_",1)
	}
	var regex = regexp.MustCompile(`(\|| |=|\)|\(|&|<|>|,|\+|-|!|\*|\/)(r|p)\.`)
	s = regex.ReplaceAllStringFunc(s, func(m string) string {
		return strings.Replace(m, ".", "_", 1)
	})
	return s
}
753522
func EscapePath(path string, encodeSep bool) string {
	var buf bytes.Buffer
	for i := 0; i < len(path); i++ {
		c := path[i]
		if noEscape[c] || (c == '/' && !encodeSep) {
			buf.WriteByte(c)
		} else {
			fmt.Fprintf(&buf, "%%%02X", c)
		}
	}
	return buf.String()
}
527402
func EscapeCommand(argv []string) string {
	var escaped []string
	for _, arg := range argv {
		escaped = append(escaped, escapeArg(arg))
	}
	return strings.Join(escaped, " ")
}
673825
func escapeTag(tag reflect.StructTag) string {
	t := string(tag)
	if strings.ContainsRune(t, '`') {
		// there are ` in the string; we can't use ` to enclose the string
		return strconv.Quote(t)
	}
	return "`" + t + "`"
}
923053
func escapeStr(s string, charsToEscape string) string {
	var ret string
	for _, currRune := range s {
		appended := false
		for _, escapableRune := range charsToEscape {
			if currRune == escapableRune {
				ret += `\` + string(currRune)
				appended = true
				break
			}
		}
		if !appended {
			ret += string(currRune)
		}
	}
	return ret
}
587126
func (e *LikeExp) Escape(chars ...string) *LikeExp {
	e.escape = chars
	return e
}
1135485
func (f *Queries) Escape(key string) (string, error) {
	s, err := f.String(key)
	if err != nil {
		return "", err
	}
	return template.HTMLEscapeString(s), nil
}
1283498
func (p *printer) EscapeString(s string) {
	var esc []byte
	last := 0
	for i := 0; i < len(s); {
		r, width := utf8.DecodeRuneInString(s[i:])
		i += width
		switch r {
		case '"':
			esc = esc_quot
		case '\'':
			esc = esc_apos
		case '&':
			esc = esc_amp
		case '<':
			esc = esc_lt
		case '>':
			esc = esc_gt
		case '\t':
			esc = esc_tab
		case '\n':
			esc = esc_nl
		case '\r':
			esc = esc_cr
		default:
			if !isInCharacterRange(r) || (r == 0xFFFD && width == 1) {
				esc = esc_fffd
				break
			}
			continue
		}
		p.WriteString(s[last : i-width])
		p.Write(esc)
		last = i
	}
	p.WriteString(s[last:])
}
1136991
func substitutePrefix(str, key, val string) string {
	key = fmt.Sprintf("\\${%s##(.+)}", key)
	reg, err := regexp.Compile(key)
	if err != nil {
		return str
	}
	for _, match := range reg.FindAllStringSubmatch(str, -1) {
		if len(match) != 2 {
			continue
		}
		val_ := strings.TrimPrefix(val, match[1])
		str = strings.Replace(str, match[0], val_, -1)
	}
	return str
}
680709
func escape(s string) string {
	var b bytes.Buffer
	for _, c := range []byte(s) {
		if c < 0x20 || c >= 0x7f || c == ' ' || c == '#' || c == '%' {
			b.WriteString(fmt.Sprintf("%%%02x", c))
		} else {
			b.WriteByte(c)
		}
	}
	return b.String()
}
700280
func Elide(types ...string) Option {
	return Map(func(token lexer.Token) (lexer.Token, error) {
		return lexer.Token{}, DropToken
	}, types...)
}
815391
func bashEscape(s string) string {
	return escapeRegExp.ReplaceAllStringFunc(s, func(c string) string {
		if c == `\` {
			return `\\\\`
		}
		return `\\` + c
	})
}
85923
func (i *Identifier) String() string {
	return fmt.Sprintf("%s: %T{Val: %q}", i.p, i, i.Val)
}
1050477
func (q *QueryStringQuery) Escape(escape bool) *QueryStringQuery {
	q.escape = &escape
	return q
}
871896
func (enc *Encoder) Indent(prefix, indent string) {
	enc.p.prefix = prefix
	enc.p.indent = indent
}