host_normalize: Normalize hosts to canonical comparison form

View source: R/normalize.R

host_normalizeR Documentation

Normalize hosts to canonical comparison form

Description

Converts DNS hostnames to their canonical comparison form following the ratified canonical-host normalization contract: Unicode NFC, case mapping, UTS-46 label mapping and validation (non-transitional, with 'UseSTD3ASCIIRules', 'CheckHyphens', 'CheckBidi', and 'CheckJoiners'), conversion to lowercase ASCII A-labels, and DNS length verification, while preserving whether the input carried a single terminal root dot.

Usage

host_normalize(x, strict = TRUE)

Arguments

x

Character vector of hostnames. 'NA' elements pass through as 'NA' (missing, not invalid). Names are preserved.

strict

Logical scalar. 'TRUE' (the default) applies the full profile. 'strict = FALSE' is reserved for a future documented relaxed variant and currently behaves identically to 'TRUE'. This function never reads the 'punycoder.strict' option.

Details

Unlike [puny_encode()], invalid input is reported by returning 'NA_character_' (never by aborting), so a caller can layer its own policy. The profile is fixed at one pinned Unicode version per release; see [normalization_profile_info()] for the machine-readable identity.

Value

A character vector the same length as 'x'. Each element is the canonical lowercase ASCII A-label host, or 'NA_character_' when the input is 'NA' or invalid under the profile.

See Also

[normalization_profile_info()] for the profile identity, [puny_encode()] for the lower-level RFC 3492 transform.

Examples

host_normalize(c("Example.COM", "münchen.de", "example.com."))
host_normalize("a_b.com") # NA: STD3 rejects "_"

punycoder documentation built on June 16, 2026, 9:07 a.m.