The OpenD Programming Language

normalize

Returns input string normalized to the chosen form. Form C is used by default.

For more information on normalization forms see the normalization section.

Note: In cases where the string in question is already normalized, it is returned unmodified and no memory allocation happens.

version(!std_uni_bootstrap)
pure @safe
inout(C)[]
normalize
(
NormalizationForm norm = NFC
C
)
(
return scope inout(C)[] input
)

Examples

// any encoding works
wstring greet = "Hello world";
assert(normalize(greet) is greet); // the same exact slice

// An example of a character with all 4 forms being different:
// Greek upsilon with acute and hook symbol (code point 0x03D3)
assert(normalize!NFC("ϓ") == "\u03D3");
assert(normalize!NFD("ϓ") == "\u03D2\u0301");
assert(normalize!NFKC("ϓ") == "\u038E");
assert(normalize!NFKD("ϓ") == "\u03A5\u0301");

Meta