File: nfkc.rb

package info (click to toggle)
ruby-unicode-utils 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,988 kB
  • sloc: ruby: 1,877; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- encoding: utf-8 -*-

require "unicode_utils/compatibility_decomposition"
require "unicode_utils/nfc"

module UnicodeUtils

  # Get +str+ in Normalization Form KC.
  #
  # Normalization Form KC is compatibiliy decomposition (NFKD)
  # followed by composition. Like NFKD, this normalization can alter
  # how a string is displayed.
  #
  # Example:
  #
  #   require "unicode_utils/nfkc"
  #   # LATIN SMALL LIGATURE FI => LATIN SMALL LETTER F, LATIN SMALL LETTER I
  #   UnicodeUtils.nfkc("fi") => "fi"
  #
  # See also: UnicodeUtils.compatibility_decomposition
  def nfkc(str)
    str = UnicodeUtils.compatibility_decomposition(str)
    Impl.composition(str)
  end
  module_function :nfkc

end