method
g_unpack
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.
g_unpack(str)protected
Unpack the string at grapheme boundaries instead of codepoint boundaries
# File activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb, line 390
def g_unpack(str)
codepoints = u_unpack(str)
unpacked = []
pos = 0
marker = 0
eoc = codepoints.length
while(pos < eoc)
pos += 1
previous = codepoints[pos-1]
current = codepoints[pos]
if (
# CR X LF
one = ( previous == UCD.boundary[:cr] and current == UCD.boundary[:lf] ) or
# L X (L|V|LV|LVT)
two = ( UCD.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) ) or
# (LV|V) X (V|T)
three = ( in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t]) ) or
# (LVT|T) X (T)
four = ( in_char_class?(previous, [:lvt,:t]) and UCD.boundary[:t] === current ) or
# X Extend
five = (UCD.boundary[:extend] === current)
)
else
unpacked << codepoints[marker..pos-1]
marker = pos
end
end
unpacked
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