Function idna::domain_to_ascii_cow

source ·
pub fn domain_to_ascii_cow(
    domain: &[u8],
    ascii_deny_list: AsciiDenyList,
) -> Result<Cow<'_, str>, Errors>
Expand description

The domain to ASCII algorithm; version returning a Cow.

Most applications should be using this function rather than the sibling functions, and most applications should pass AsciiDenyList::URL as the second argument. Passing AsciiDenyList::URL as the second argument makes this function also perform the forbidden domain code point check in addition to the domain to ASCII algorithm.

Returns the ASCII representation a domain name, normalizing characters (upper-case to lower-case and other kinds of equivalence) and using Punycode as necessary.

This process may fail.

If you have a &str instead of &[u8], just call .to_bytes() on it before passing it to this function. It’s still preferable to use this function over the sibling functions that take &str.