golang url编码
在 Go语言中,可以使用标准库中的 net/url 包来进行 URL解码,可以使用 url.QueryUnescape 函数来URL解码被URL编码的字符串。
package main
import (
"fmt"
"net/url"
)
func main() {
// URL编码的字符串
encodedUrl := "Hello%20World%21%20%40%20Go%20URL%20Decoding"
// 使用Golang的 QueryUnescape 进行URL解码
decodedUrl, err := url.QueryUnescape(encodedUrl)
if err != nil {
fmt.Println("Error decoding URL:", err)
return
}
// 输出结果
fmt.Println("Decoded URL:", decodedUrl)
}
URL Decode 在线解码工具
这是一个简单易用的在线URL解码工具,就是简单快捷地进行各种字符的URL解码或编码操作。您的数据可以轻松地编码为 URL 编码,也可以解码为人类可理解的格式。UrlEncode是为了将字符转换为可在URL中安全传输的格式的编码方法。它将非字母数字字符转换为百分号(%)后跟两位十六进制数。UrlDecode就是将Url编码后的转换为编码前的字符。
(输入框内容为示例,删除重新输入即可)
结果:
复制成功
Url编码特殊符号编码表
| 符号 | 编码 |
|---|---|
| 空格 | %20 |
| ! | %21 |
| # | %23 |
| $ | %24 |
| & | %26 |
| ' | %27 |
| ( | %28 |
| ) | %29 |
| * | %2A |
| + | %2B |
| , | %2C |
| / | %2F |
| : | %3A |
| ; | %3B |
| = | %3D |
| ? | %3F |
| @ | %40 |
| [ | %5B |
| ] | %5D |