method
compose_codepoints
rails latest stable - Class:
ActiveSupport::Multibyte::Handlers::UTF8Handler
Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v2.1.0) is shown here.
compose_codepoints(codepoints)protected
Compose decomposed characters to the composed form
# File activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb, line 503
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[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
- Class methods
- []=
- capitalize
- center
- codepoints_to_pattern
- compose
- consumes?
- decompose
- downcase
- g_length
- index
- insert
- ljust
- lstrip
- normalize
- reverse
- rjust
- rstrip
- size
- slice
- strip
- tidy_bytes
- translate_offset
- upcase
- Protected methods
-
compose_codepoints -
decompose_codepoints -
g_pack -
g_unpack -
in_char_class? -
justify -
padding -
reorder_characters -
to_case -
u_unpack