struct
Pf::GraphemeView
- Pf::GraphemeView
- Struct
- Value
- Object
Overview
Represents a single grapheme as a view into a string.
NOTE GraphemeView, just like GraphemeSeln, refers back to the trunk
string, which could be very large. This may prevent the GC from freeing large
chunks of memory due to a small number of grapheme views that refer to it. For
this reason, you are advised not to store GraphemeViews on the heap unless
you know for sure their lifetime is less than or equal to the lifetime of the trunk
string. Otherwise, use #to_grapheme. In general, when working with GraphemeView,
the reasoning should be the same as with GraphemeSeln; in that they carry around,
at least conceptually, the larger context as well.
EXPERIMENTAL Relies on features from the experimental String::Grapheme API.
Defined in:
permafrost/grapheme_view.crInstance Method Summary
-
#==(other : Char) : Bool
Returns
trueif this view consists only of the character other. -
#==(other : String) : Bool
Compares the contents of this view with other, bytewise.
-
#byte_end : Int32
Returns the byte index of this grapheme in the trunk string.
-
#byte_range : Range(Int32, Int32)
Returns an exclusive range of the indices of the contituent bytes of this grapheme in the trunk string.
-
#byte_start : Int32
Returns the byte index of this grapheme in the trunk string.
-
#bytesize : Int32
Returns the size of this grapheme in bytes.
- #inspect(io)
-
#to_grapheme : String::Grapheme
Converts this view to a
String::Grapheme. - #to_s(io)
-
#to_slice : Bytes
Returns a read-only view of the underling bytes of this grapheme.
Instance Method Detail
Returns an exclusive range of the indices of the contituent bytes of this grapheme in the trunk string.
Returns a read-only view of the underling bytes of this grapheme. The view is a subview of the trunk string's bytes.