Is there an equivalent of Javascript's unescape() in golang?
Javscript example:
<script>
var c = unescape('%u0107'); // "ć"
console.log(c);
</script>
CodePudding user response:
The unescape
function is marked as "Deprecated" (red trash can), in the
Mozilla documentation [1]. As such, I wouldnt recommend using it, and certainly
not seeking out an equivalent Go function. Go has a similar function [2], but it
expects different input from what you have provided:
package main
import "net/url"
func main() {
s, err := url.PathUnescape("ć")
if err != nil {
panic(err)
}
println(s == "ć")
}
If you are really set on doing this, you could see about translating this polyfill [3].