Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  UNICODE::GCSTRING (3)

.ds Aq ’


Unicode::GCString - String as Sequence of UAX #29 Grapheme Clusters



    use Unicode::GCString;
    $gcstring = Unicode::GCString->new($string);


Unicode::GCString treats Unicode string as a sequence of extended grapheme clusters defined by Unicode Standard Annex #29 [UAX #29].

<B>Grapheme clusterB> is a sequence of Unicode character(s) that consists of one <B>grapheme baseB> and optional <B>grapheme extenderB> and/or <B>XprependX characterB>. It is close in that people consider as character.

    Public Interface

new (STRING, [KEY => VALUE, ...])
new (STRING, [LINEBREAK]) Constructor. Create new grapheme cluster string (Unicode::GCString object) from Unicode string STRING.

About optional KEY => VALUE pairs see Options in Unicode::LineBreak. On second form, Unicode::LineBreak object LINEBREAK controls breaking features.

<B>NoteB>: The first form was introduced by release 2012.10.

copy Copy constructor. Create a copy of grapheme cluster string. Next position of new string is set at beginning.
chars Instance method. Returns number of Unicode characters grapheme cluster string includes, i.e. length as Unicode string.
columns Instance method. Returns total number of columns of grapheme clusters defined by built-in character database. For more details see DESCRIPTION in Unicode::LineBreak.
length Instance method. Returns number of grapheme clusters contained in grapheme cluster string.
Operations as String
‘‘OBJECT’’ Instance method. Convert grapheme cluster string to Unicode string explicitly.
cmp (STRING)
STRING cmp STRING Instance method. Compare strings. There are no oddities. One of each STRING may be Unicode string.
concat (STRING)
STRING . STRING Instance method. Concatenate STRINGs. One of each STRING may be Unicode string. Note that number of columns (see columns()) or grapheme clusters (see length()) of resulting string is not always equal to sum of both strings. Next position of new string is that set on the left value.
join ([STRING, ...]) Instance method. Join STRINGs inserting grapheme cluster string. Any of STRINGs may be Unicode string.
substr (OFFSET, [LENGTH, [REPLACEMENT]]) Instance method. Returns substring of grapheme cluster string. OFFSET and LENGTH are based on grapheme clusters. If REPLACEMENT is specified, substring is replaced by it. REPLACEMENT may be Unicode string.

Note: This method cannot return the lvalue, unlike built-in substr().

Operations as Sequence of Grapheme Clusters
as_arrayref Instance method. Convert grapheme cluster string to an array of grapheme clusters.
eos Instance method. Test if current position is at end of grapheme cluster string.
item ([OFFSET]) Instance method. Returns OFFSET-th grapheme cluster. If OFFSET was not specified, returns next grapheme cluster.
<OBJECT> Instance method, iterative. Returns next grapheme cluster and increment next position.
pos ([OFFSET]) Instance method. If optional OFFSET is specified, set next position by it. Returns next position of grapheme cluster string.
lbc Instance method. Returns Line Breaking Class (See Unicode::LineBreak) of the first character of first grapheme cluster.
lbcext Instance method. Returns Line Breaking Class (See Unicode::LineBreak) of the last grapheme extender of last grapheme cluster. If there are no grapheme extenders or its class is CM, value of last grapheme base will be returned.


o The grapheme cluster should not be referred to as grapheme even though Larry does.
o On Perl around 5.10.1, implicit conversion from Unicode::GCString object to Unicode string sometimes let "utf8_mg_pos_cache_update" cache be confused.

For example, instead of doing

    $sub = substr($gcstring, $i, $j);


    $sub = substr("$gcstring", $i, $j);

    $sub = substr($gcstring->as_string, $i, $j);

o This module implements default algorithm for determining grapheme cluster boundaries. Tailoring mechanism has not been supported yet.


Consult $VERSION variable.

    Incompatible Changes

Release 2013.10
o The new() method can take non-Unicode string argument. In this case it will be decoded by iso-8859-1 (Latin 1) character set. That method of former releases would die with non-Unicode inputs.


[UAX #29] Mark Davis (ed.) (2009-2013). Unicode Standard Annex #29: Unicode Text Segmentation, Revisions 15-23. <>.


Hatuka*nezumi - IKEDA Soji <hatuka(at)>


Copyright (C) 2009-2013 Hatuka*nezumi - IKEDA Soji.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 UNICODE::GCSTRING (3) 2013-11-21

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.