Module: UnicodeUtils::Impl::NFC

Defined in:
lib/unicode_utils/nfc.rb

Class Method Summary collapse

Class Method Details

.blocked?(b, c) ⇒ Boolean

does b block c?

Returns:

  • (Boolean)

25
26
27
28
29
30
31
32
33
# File 'lib/unicode_utils/nfc.rb', line 25

def self.blocked?(b, c)
  # From the standard:
  # "If a combining character sequence is in canonical order,
  # then testing whether a character is blocked requires looking
  # at only the immediately preceding character."
  # cpary is in canonical order (since it comes out of
  # canonical_decomposition).
  COMBINING_CLASS_MAP[b] >= COMBINING_CLASS_MAP[c]
end

.primary_composite?(cp) ⇒ Boolean

Returns:

  • (Boolean)

35
36
37
38
39
40
41
42
# File 'lib/unicode_utils/nfc.rb', line 35

def self.primary_composite?(cp)
  unless CANONICAL_DECOMPOSITION_MAP[cp] ||
      # has hangul syllable decomposition?
      (cp >= 0xAC00 && cp <= 0xD7A3)
    return false
  end
  !COMPOSITION_EXCLUSION_SET.include?(cp)
end