Skip to contents

Determines whether a given string or domain name is already encoded in punycode format (starts with xn– prefix).

Usage

is_punycode(x)

Arguments

x

Character vector to test

Value

A logical vector the same length as x, where TRUE indicates the element contains a punycode-encoded label (xn– prefix). Never NA and never an error: an element that is not well-formed UTF-8 is reported as FALSE, matching is_idn and base R's own validUTF8. Use validUTF8(x) to tell "not punycode" apart from "not well-formed text".

See also

is_idn for detecting Unicode domains, puny_decode for decoding punycode domains.

Examples

is_punycode("xn--example") # TRUE
#> [1] TRUE
is_punycode("example.com") # FALSE
#> [1] FALSE
is_punycode(c("xn--caf-dma.com", "regular.com")) # c(TRUE, FALSE)
#> [1]  TRUE FALSE