1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
package Unicode::GCString; require 5.008; use strict; use warnings; use vars qw($VERSION @EXPORT_OK @ISA); use Exporter; our @EXPORT_OK = qw(); our %EXPORT_TAGS = ('all' => [@EXPORT_OK]); our @ISA = qw(Exporter); use Unicode::LineBreak; our $VERSION = '2013.10'; use overload '@{}' => \&as_arrayref, '${}' => \&as_scalarref, '""' => \&as_string, '.' => \&concat, #XXX'.=' => \&concat, #FIXME:segfault 'cmp' => \&cmp, '<>' => \&next, ; sub new { my $class = shift; my $self; if (scalar @_ <= 2) { $self = __PACKAGE__->_new(@_); } else { my $str = shift; my $lb = Unicode::LineBreak->new(@_); $self = __PACKAGE__->_new($str, $lb); } bless $self, $class; } sub as_arrayref { my @a = shift->as_array; return \@a; } 1;