method
compose_codepoints
v2.3.8 -
Show latest stable
- Class:
ActiveSupport::Multibyte::Chars
compose_codepoints(codepoints)public
Compose decomposed characters to the composed form.
# File activesupport/lib/active_support/multibyte/chars.rb, line 577
def compose_codepoints(codepoints)
pos = 0
eoa = codepoints.length - 1
starter_pos = 0
starter_char = codepoints[0]
previous_combining_class = -1
while pos < eoa
pos += 1
lindex = starter_char - HANGUL_LBASE
# -- Hangul
if 0 <= lindex and lindex < HANGUL_LCOUNT
vindex = codepoints[starter_pos+1] - HANGUL_VBASE rescue vindex = -1
if 0 <= vindex and vindex < HANGUL_VCOUNT
tindex = codepoints[starter_pos+2] - HANGUL_TBASE rescue tindex = -1
if 0 <= tindex and tindex < HANGUL_TCOUNT
j = starter_pos + 2
eoa -= 2
else
tindex = 0
j = starter_pos + 1
eoa -= 1
end
codepoints[starter_pos..j] = (lindex * HANGUL_VCOUNT + vindex) * HANGUL_TCOUNT + tindex + HANGUL_SBASE
end
starter_pos += 1
starter_char = codepoints[starter_pos]
# -- Other characters
else
current_char = codepoints[pos]
current = UCD.codepoints[current_char]
if current.combining_class > previous_combining_class
if ref = UCD.composition_map[starter_char]
composition = ref[current_char]
else
composition = nil
end
unless composition.nil?
codepoints[starter_pos] = composition
starter_char = composition
codepoints.delete_at pos
eoa -= 1
pos -= 1
previous_combining_class = -1
else
previous_combining_class = current.combining_class
end
else
previous_combining_class = current.combining_class
end
if current.combining_class == 0
starter_pos = pos
starter_char = codepoints[pos]
end
end
end
codepoints
end Related methods
- Instance methods
- +
- <=>
- =~
- []
- []=
- acts_like_string?
- capitalize
- center
- compose
- decompose
- downcase
- g_length
- include?
- index
- insert
- length
- ljust
- lstrip
- method_missing
- normalize
- ord
- respond_to?
- reverse
- rindex
- rjust
- rstrip
- size
- slice
- slice!
- split
- strip
- tidy_bytes
- upcase
- Class methods
- codepoints_to_pattern
- compose_codepoints
- consumes?
- decompose_codepoints
- g_pack
- g_unpack
- in_char_class?
- new
- new
- padding
- reorder_characters
- tidy_bytes
- u_unpack
- wants?
- Protected methods
-
apply_mapping -
chars -
justify -
translate_offset