instance method
String#unicode_normalize
(?:nfc | :nfd | :nfkc | :nfkd form) -> self
unicode_normalize(form = :nfc) → string
string.c
View on GitHub ↗
static VALUE
rb_str_unicode_normalize(int argc, VALUE *argv, VALUE str)
{
return unicode_normalize_common(argc, argv, str, id_normalize);
}
Returns a copy of self with Unicode normalization applied.
Argument form must be one of the following symbols (see Unicode normalization forms):
-
:nfc: Canonical decomposition, followed by canonical composition. -
:nfd: Canonical decomposition. -
:nfkc: Compatibility decomposition, followed by canonical composition. -
:nfkd: Compatibility decomposition.
The encoding of self must be one of:
-
Encoding::UTF_8. -
Encoding::UTF_16BE. -
Encoding::UTF_16LE. -
Encoding::UTF_32BE. -
Encoding::UTF_32LE. -
Encoding::GB18030. -
Encoding::UCS_2BE. -
Encoding::UCS_4BE.
Examples:
Example
"a\u0300".unicode_normalize # => "à" # Lowercase 'a' with grave accens. "a\u0300".unicode_normalize(:nfd) # => "à" # Same.
Related: see Converting to New String.
See also
#unicode_normalize!
#undump
#tr_s!
#unicode_normalized?
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0