View source code
Display the source code in std/uni.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.uni.normalize

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

inout(C)[] normalize(NormalizationForm norm = NFC, C) (
  scope return inout(C)[] input
) pure @safe;

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.

Example

// 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)
writeln(normalize!NFC("ϓ")); // "\u03D3"
writeln(normalize!NFD("ϓ")); // "\u03D2\u0301"
writeln(normalize!NFKC("ϓ")); // "\u038E"
writeln(normalize!NFKD("ϓ")); // "\u03A5\u0301"

Authors

Dmitry Olshansky

License

Boost License 1.0.