method
normalized?

v2_4_6 -
Show latest stable
-
0 notes -
Class: UnicodeNormalize
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
normalized?(string, form = :nfc)
public
Hide source
# File lib/unicode_normalize/normalize.rb, line 129 def self.normalized?(string, form = :nfc) encoding = string.encoding case encoding when Encoding::UTF_8 case form when :nfc then string.scan REGEXP_C do |match| return false if NF_HASH_C[match] != match end true when :nfd then string.scan REGEXP_D do |match| return false if NF_HASH_D[match] != match end true when :nfkc then normalized?(string, :nfc) and string !~ REGEXP_K when :nfkd then normalized?(string, :nfd) and string !~ REGEXP_K else raise ArgumentError, "Invalid normalization form #{form}." end when Encoding::US_ASCII true when *UNICODE_ENCODINGS normalized? string.encode(Encoding::UTF_8), form else raise Encoding::CompatibilityError, "Unicode Normalization not appropriate for #{encoding}" end end