End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
String#unicode_normalized?
str.unicode_normalized?(form=:nfc)
string.c
View on GitHub ↗
static VALUE
rb_str_unicode_normalized_p(int argc, VALUE *argv, VALUE str)
{
return unicode_normalize_common(argc, argv, str, id_normalized_p);
}
Checks whether str is in Unicode normalization form form, which can be any of the four values :nfc, :nfd, :nfkc, or :nfkd. The default is :nfc.
If the string is not in a Unicode Encoding, then an Exception is raised. For details, see String#unicode_normalize.
Example
"a\u0300".unicode_normalized? #=> false "a\u0300".unicode_normalized?(:nfd) #=> true "\u00E0".unicode_normalized? #=> true "\u00E0".unicode_normalized?(:nfd) #=> false "\xE0".force_encoding('ISO-8859-1').unicode_normalized? #=> Encoding::CompatibilityError raised
See also
#unicode_normalize!
#unpack
#unicode_normalize
#unpack1
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1