View Source Unicode.String.Case.Folding (Unicode String v1.4.1)
Implements the Unicode Case Folding algorithm.
The intention of case folding is to facilitate case-insensitive string comparisons. It is not intended to be a general purpose transformation.
Although case folding does generally use lower
case as its normal form, it is not true for
all scripts and codepoints. Therefore case
folding should not be used as an alternative
to String.downcase/1
.
Summary
Functions
Case fold a string.
Returns a string after applying the Unicode Case Folding algorithm.
Case folding is intended to suport case
insensitve string comparisons such as that
implemented by Unicode.String.equals_ignoring_case?/2
which
calls this function on its parameters.
Arguments
string
is anyString.t()
mode or language tag
is either the atoms:turkic
ornil
or a map that includes the key:language
with a value that is a lowercase atom representing an ISO 639-1 language code. The CLDR language tag which is defined as part of the ex_cldr is one such example. See Cldr.validate_locale/2 for further information. The default isnil
.
Returns
- The case folded string
Notes
No normalization is applied to the string on either input or output.
Case folding does not apply any transformation to accented characters.
"ü"
will not case fold to"u"
for example.
Examples
iex> Unicode.String.Case.Folding.fold("THIS")
"this"
iex> Unicode.String.Case.Folding.fold("grüßen")
"grüssen"
iex(13)> Unicode.String.Case.Folding.fold("I")
"i"
# Turkic languages such as Turkish and Azerbaijani have
# a dotless lower case "i"
iex> Unicode.String.Case.Folding.fold("I", :turkic)
"ı"
iex> Unicode.String.Case.Folding.fold("I", %{language: :az})
"ı"