Module: Ucode::Unicode

Defined in:
lib/ucode/unicode.rb,
lib/ucode/unicode/block.rb,
lib/ucode/unicode/plane.rb,
lib/ucode/unicode/catalog.rb,
lib/ucode/unicode/metadata_writer.rb,
lib/ucode/unicode/metadata/v15_0_0.rb,
lib/ucode/unicode/metadata/v15_1_0.rb,
lib/ucode/unicode/metadata/v16_0_0.rb,
lib/ucode/unicode/metadata/v17_0_0.rb

Overview

Unicode metadata Ruby API.

Provides version-specific access to plane, block, and assigned-codepoint counts without requiring UCD text files at runtime. Metadata is shipped as frozen Ruby constants (one module per Unicode version) so consumers get O(1) lookup with no file I/O.

Multiple Unicode versions are supported simultaneously — a consumer auditing a Unicode 16.0 font queries v16 metadata while the gem also ships v17 as the default.

Examples:

Default (latest version)

Ucode::Unicode.assigned_count         # => 159_866
Ucode::Unicode.find_block("Basic_Latin")

Version-specific

catalog = Ucode::Unicode.for_version("16.0")
catalog.assigned_count                # => v16 count (different)
catalog.find_plane_by_codepoint(0x41)

Defined Under Namespace

Modules: Metadata, MetadataWriter Classes: Block, Catalog, Plane

Constant Summary collapse

SUPPORTED_VERSIONS =
%w[15.0.0 15.1.0 16.0.0 17.0.0].freeze
LATEST_VERSION =
"17.0.0"
PLANE_NAMES =

Official Unicode plane short names. Planes 4–13 are unassigned and have no short name. Used by Catalog when building Plane objects.

{
  0 => { short_name: :BMP, display_name: "Basic Multilingual Plane" },
  1 => { short_name: :SMP, display_name: "Supplementary Multilingual Plane" },
  2 => { short_name: :SIP, display_name: "Supplementary Ideographic Plane" },
  3 => { short_name: :TIP, display_name: "Tertiary Ideographic Plane" },
  14 => { short_name: :SSP, display_name: "Supplementary Special-purpose Plane" },
  15 => { short_name: :"SPUA-A", display_name: "Supplementary Private Use Area-A" },
  16 => { short_name: :"SPUA-B", display_name: "Supplementary Private Use Area-B" },
}.freeze

Class Method Summary collapse

Class Method Details

.assigned_countObject



62
63
64
# File 'lib/ucode/unicode.rb', line 62

def assigned_count
  for_version.assigned_count
end

.for_version(version = LATEST_VERSION) ⇒ Object



58
59
60
# File 'lib/ucode/unicode.rb', line 58

def for_version(version = LATEST_VERSION)
  Catalog.new(version: normalize_version(version))
end

.unicode_versionObject



66
67
68
# File 'lib/ucode/unicode.rb', line 66

def unicode_version
  LATEST_VERSION
end