1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/unicode_normalize.rb
duerst 90ab1ee023 move definition of String#unicode_normalize! to C to make sure it is documented
* lib/unicode_normalize.rb: Remove definition of String#unicode_normalize!
  (including documentation)
* string.c: Define String#unicode_normalize! in rb_str_unicode_normalize_bang in C,
  (including documentation)
* lib/unicode_normalize/normalize.rb: Remove (re)definition of
  String#unicode_normalize! to avoid warnings (when $VERBOSE==true) and
  problems when String is frozen

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-04 01:36:52 +00:00

32 lines
1 KiB
Ruby

# coding: utf-8
# frozen_string_literal: false
# Copyright Ayumu Nojima (野島 歩) and Martin J. Dürst (duerst@it.aoyama.ac.jp)
#--
# additions to class String for Unicode normalization
#++
class String
# :call-seq:
# str.unicode_normalized?(form=:nfc)
#
# 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.
#
# "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
#
def unicode_normalized?(form = :nfc)
require 'unicode_normalize/normalize.rb'
unicode_normalized? form
end
end