Code: Select all
DecodeEscapeChar(str) {
static esc := {n: "`n", r: "`r", b: "`b", t: "`t", v: "`v", a: "`a", f: "`f"}
static output
output := ""
loop {
count := 0
str := RegExReplace(str, "(.*?)(\\)(.)(?CCallout)", , &c)
count += c
} until !count
output .= str
return output
Callout(m, *) {
output .= m[1] . (m[3] = "\" ? m[3] : esc.HasOwnProp(m[3]) ? esc.%m[3]% : "")
}
}
msgbox DecodeEscapeChar("1\n2\n3")
msgbox DecodeEscapeChar("1\n2\n3")