File: general_category.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-- 663 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/read_cdata"
require "unicode_utils/gc"

module UnicodeUtils

  GENERAL_CATEGORY_ALIAS_MAP =
    Impl.read_symbol_map("general_category_aliases") # :nodoc:

  # Get the long general category alias of char.
  #
  # Example:
  #
  #   require "unicode_utils/general_category"
  #   UnicodeUtils.general_category("A") # => :Uppercase_Letter
  #
  # Returns a symbol if char is in the Unicode code point range, nil
  # otherwise.
  #
  # See also: UnicodeUtils.gc, UnicodeUtils.char_type
  def general_category(char)
    GENERAL_CATEGORY_ALIAS_MAP[UnicodeUtils.gc(char)]
  end
  module_function :general_category

end