| url_encode | R Documentation |
Converts URLs containing Unicode domain names to their ASCII representation while preserving the rest of the URL structure. This function is essential for preparing URLs for systems that require ASCII-only domain names.
url_encode(url, strict = getOption("punycoder.strict", TRUE))
url |
Character vector of URLs with potential Unicode domains |
strict |
Logical; whether to apply strict validation. Defaults to 'getOption("punycoder.strict", TRUE)'. |
A character vector the same length as url, with each element
containing the URL with its host portion ASCII-encoded. Only the domain
component is transformed; scheme, path, query, and fragment are preserved.
Elements corresponding to NA inputs are NA_character_.
url_decode for the reverse operation,
puny_encode for domain-only encoding,
parse_url for URL component extraction.
# Basic URL encoding
url_encode("https://caf\u00E9.example.com/path?query=value")
url_encode(
"https://\u043C\u043E\u0441\u043A\u0432\u0430.\u0440\u0444/page"
)
# Vectorized URL encoding
urls <- c(
"https://caf\u00E9.com/menu",
"https://\u5317\u4EAC.\u4E2D\u56FD/info"
)
url_encode(urls)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.