Процентное кодирование URL представляет текст UTF-8 байтовыми последовательностями %HH. Инструмент следует поведению encodeURIComponent: буквы, цифры и -_.!~*'() остаются читаемыми, а остальные байты, включая разделители URL и не-ASCII текст, экранируются.
Кодируйте отдельные сегменты пути или значения запроса до сборки URL, чтобы пробелы, &, =, ? и Unicode не меняли его структуру. Инструмент не разбирает URL целиком и не считает + пробелом, отклоняет неверные %‑последовательности и выполняет кодирование, а не шифрование.
# Encoding
printf 'Hello, World!' | jq -sRr @uri
# Output: Hello%2C%20World%21
# Decoding
printf 'Hello%2C%20World%21' | jq -sRr @urid
# Output: Hello, World!
// Encoding
let encoded = encodeURIComponent("Hello, World!");
console.log(encoded);
// Output: Hello%2C%20World%21
// Decoding
let decoded = decodeURIComponent("Hello%2C%20World%21");
console.log(decoded);
// Output: Hello, World!
package main
import (
"fmt"
"net/url"
)
func main() {
// Encoding
encoded := url.QueryEscape("Hello, World!")
fmt.Println(encoded)
// Output: Hello%2C+%21World%21 (QueryEscape uses + for spaces)
// Decoding
decoded, _ := url.QueryUnescape("Hello%2C%20World%21")
fmt.Println(decoded)
// Output: Hello, World!
}
// Encoding
$encoded = urlencode("Hello, World!");
echo $encoded . "\n";
// Output: Hello%2C+%21World%21
// Decoding
$decoded = urldecode("Hello%2C%20World%21");
echo $decoded . "\n";
// Output: Hello, World!