url_encode()url_encode()

此函数将输入 URL 的字符转换为可通过 Internet 传输的格式。The function converts characters of the input URL into a format that can be transmitted over the Internet.

语法Syntax

url_encode(url)url_encode(url)

参数Arguments

  • url:输入 URL(字符串)。url : input URL (string).

返回Returns

URL(字符串),已转换为可通过 Internet 传输的格式。URL (string) converted into a format that can be transmitted over the Internet.

示例Examples

let url = @'https://www.bing.com/hello word';
print original = url, encoded = url_encode(url)
原配original 已编码encoded
https://www.bing.com/hello word/https://www.bing.com/hello word/ https%3a%2f%2f www.bing.com%2fhello+wordhttps%3a%2f%2fwww.bing.com%2fhello+word