normalize
The normalize() method returns a new string normalized according to the specified Unicode form.
Interactive example
Syntax
typescript
type NormalizeForm = "NFC" | "NFD" | "NFKC" | "NFKD";Classic signature
typescript
function normalize<
GenericInput extends string
>(
input: GenericInput,
form: NormalizeForm
): string;Curried signature
typescript
function normalize<
GenericInput extends string
>(
form: NormalizeForm
): (input: GenericInput) => string;Parameters
input: The string to normalize.form: The Unicode normalization form to use. Options are:"NFC"(Normalization Form C): Composed, where accented characters are represented by a single code point."NFD"(Normalization Form D): Decomposed, where accented characters are represented by a base letter followed by separate diacritic characters."NFKC"(Normalization Form KC): Composed and compatibility, similar to NFC but with additional transformations for compatibility."NFKD"(Normalization Form KD): Decomposed and compatibility, similar to NFD but with additional transformations for compatibility.
Return value
A new string normalized according to the specified form.
See also
- toUpperCase: Converts the entire string to uppercase.
- toLowerCase: Converts the entire string to lowercase.
- repeat: Repeats a string a specified number of times.
- trim: Removes whitespace at the start and end of a string.
