The result of escape/unescape in node.js
wants the same result in Go
.
utf8.DecodeRuneInString(src)
I couldn’t solve it.
node.js
escape("111번과 동일")
result : "111%uBC88%uACFC%20%uB3D9%uC77C"
unescape("111%uBC88%uACFC%20%uB3D9%uC77C")
result : "111번과 동일"
Go
func main() {
uniStr := "111%uBC88%uACFC%20%uB3D9%uC77C"
plainStr := strings.Split(uniStr, "%")
for i, v := range plainStr {
var err error
plainStr[i], err = strconv.Unquote(`"` + v + `"`)
if err != nil {
fmt.Errorf("Fail to Unicode to String: %v", err)
}
}
fmt.Printf(strings.Join(plainStr, ""))
}
result : "I번과동일"