Module: TwitterCldr::Normalization::Hangul

Defined in:
lib/twitter_cldr/normalization/hangul.rb

Constant Summary collapse

SBASE =
0xAC00
LBASE =
0x1100
VBASE =
0x1161
TBASE =
0x11A7
LCOUNT =
19
VCOUNT =
21
TCOUNT =
28
NCOUNT =

588

VCOUNT * TCOUNT
SCOUNT =

11172

LCOUNT * NCOUNT
LLIMIT =

0x1113 = 4371

LBASE + LCOUNT
VLIMIT =

0x1176 = 4470

VBASE + VCOUNT
TLIMIT =

0x11C3 = 4547

TBASE + TCOUNT
SLIMIT =

0xD7A4 = 55204

SBASE + SCOUNT

Class Method Summary collapse

Class Method Details

.compose(code_points) ⇒ Object

Special composition for Hangul syllables. Documented in Section 3.12 at www.unicode.org/versions/Unicode6.1.0/ch03.pdf



15
16
17
18
19
20
21
# File 'lib/twitter_cldr/normalization/hangul.rb', line 15

def compose(code_points)
  l = code_points.first - LBASE
  v = code_points[1] - VBASE
  t = code_points[2] ? code_points[2] - TBASE : 0  # T part may be missing, that's ok

  SBASE + l * NCOUNT + v * TCOUNT + t
end

.decompose(code_point) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/twitter_cldr/normalization/hangul.rb', line 26

def decompose(code_point)
  l = code_point - SBASE

  t = l % TCOUNT
  l /= TCOUNT
  v = l % VCOUNT
  l /= VCOUNT

  result = []

  result << LBASE + l
  result << VBASE + v
  result << TBASE + t if t > 0

  result
end

.hangul_syllable?(code_point) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/twitter_cldr/normalization/hangul.rb', line 43

def hangul_syllable?(code_point)
  (SBASE...SLIMIT).include?(code_point)
end