algebraicsystems/elm-unicode-normalize/1.0.0

NOTE: the latest version is 1.1.0

Unicode.Normalize

Get a Unicode Normalization Form of a string.

There are multiple ways to normalize a string, referred to as Normalization Forms. Which one you want depends on what you want to do with the string, but the most common is NFC, which preserves the exact visual appearance of the string. If you don't care about the details, just use the normalize function.

Normalization Forms

type Form
= NFC
| NFD
| NFKC
| NFKD

The different ways to normalize a string.

  • NFC: Canonical decomposition followed by canonical composition.
  • NFD: Canonical decomposition without recomposition.
  • NFKC: Compatibility decomposition followed by canonical composition.
  • NFKD: Compatibility decomposition without recomposition.

Canonical decomposition splits single characters into sequences of equivalent combining characters. Compatibilty decomposition extends canonical decomposition by also replacing variants of the same logical character (such as replacing ¼ with 1/4).

Canonical composition undoes the process of canonical decomposition, combining sequences into single characters wherever possible.

Normalize a String

normalize : Form -> String -> String

Normalize a string using a particular Normalization Form.