Changed ScriptEscape from []byte to string

This commit is contained in:
Magnus Åhall 2023-08-23 11:11:43 +02:00
parent 8dc7cdb1cd
commit be268f2f76

View File

@ -5,11 +5,11 @@ import (
"regexp"
)
func ScriptEscape(source []byte) (escaped []byte) {
func ScriptEscape(source string) (escaped string) {
rxp2 := regexp.MustCompile("([\"\\\\$])")
source = rxp2.ReplaceAll(source, []byte("\\$1"))
source = rxp2.ReplaceAllString(source, "\\$1")
rxp := regexp.MustCompile("\\r?\\n")
escaped = rxp.ReplaceAll(source, []byte("\\r\\\r\n \\n"))
escaped = rxp.ReplaceAllString(source, "\\r\\\r\n \\n")
return
}