mirror of
https://github.com/Oxalide/vsphere-influxdb-go.git
synced 2023-10-10 13:36:51 +02:00
22 lines
483 B
Go
22 lines
483 B
Go
package escape
|
|
|
|
import "strings"
|
|
|
|
var (
|
|
escaper = strings.NewReplacer(`,`, `\,`, `"`, `\"`, ` `, `\ `, `=`, `\=`)
|
|
unescaper = strings.NewReplacer(`\,`, `,`, `\"`, `"`, `\ `, ` `, `\=`, `=`)
|
|
)
|
|
|
|
// UnescapeString returns unescaped version of in.
|
|
func UnescapeString(in string) string {
|
|
if strings.IndexByte(in, '\\') == -1 {
|
|
return in
|
|
}
|
|
return unescaper.Replace(in)
|
|
}
|
|
|
|
// String returns the escaped version of in.
|
|
func String(in string) string {
|
|
return escaper.Replace(in)
|
|
}
|