I am trying to unquote a string that uses single quotes in Go (the syntax is same as Go string literal syntax but using single quotes not double quotes):
'\'"Hello,\nworld!\r\n\u1F60ANice to meet you!\nFirst Name\tJohn\nLast Name\tDoe\n'
should become
'"Hello,
world!
Nice to meet you!
First Name John
Last Name Doe
How do I accomplish this?
strconv.Unquote
doesn't work on \n
newlines (https://github.com/golang/go/issues/15893 and https://golang.org/pkg/strconv/#Unquote), and simply strings.ReplaceAll(
ing would be a pain to support all Unicode code points and other backslash codes like \n
& \r
& \t
.
I may be asking for too much, but it would be nice if it automatically validates the Unicode like how strconv.Unquote
might be able to do/is doing (it knows that x Unicode code points may become one character), since I can do the same with unicode/utf8.ValidString
.