API reference › @evolu/common › Type › normalize
function normalize<Form extends UnicodeNormalizationForm>(
value: string,
form: Form & ValidateLiteral<Form>,
): string & Brand<`Normalized${Form}`>;
Defined in: packages/common/src/Type.ts:7769
Converts a string to a Unicode normalization form and returns it with the normalized brand of that form.
Normalization can change the length, so input brands are not retained.
Example
import { assertEqual, assertType, normalize, type Brand } from "@evolu/common";
const text = normalize("cafe\u0301", "NFC");
assertEqual(text, "caf\u00E9");
assertType<typeof text, string & Brand<"NormalizedNFC">>();
assertEqual(normalize("\uFB01", "NFKC"), "fi");