Learn R Programming

punycoder (version 1.1.0)

host_normalize: 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)

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.

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.

See Also

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

Examples

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

Run the code above in your browser using DataLab