mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
483 B
22 lines
483 B
7 years ago
|
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)
|
||
|
}
|