File: white_space_char_q.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 (23 lines) | stat: -rw-r--r-- 576 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
# -*- encoding: utf-8 -*-

require "unicode_utils/read_cdata"

module UnicodeUtils

  WHITE_SPACE_SET = Impl.read_code_point_set("white_space_set") # :nodoc:

  # True if the given character has the Unicode property White_Space.
  # 
  # Example:
  #
  #   require "unicode_utils/general_category"
  #   require "unicode_utils/white_space_char_q"
  #
  #   UnicodeUtils.general_category("\n")   => :Control
  #   UnicodeUtils.white_space_char?("\n")  => true
  def white_space_char?(char)
    WHITE_SPACE_SET.include?(char.ord)
  end
  module_function :white_space_char?

end