Unicode::Util - Unicode grapheme-level versions of built-in Perl functions
This document describes Unicode::Util version 0.07.
use Unicode::Util qw( grapheme_length grapheme_reverse ); # grapheme cluster ю́ (Cyrillic small letter yu, combining acute accent) my $grapheme = "\x{044E}\x{0301}"; say length($grapheme); # 2 (length in code points) say grapheme_length($grapheme); # 1 (length in grapheme clusters) # Spın̈al Tap; n̈ = Latin small letter n, combining diaeresis my $band = "Sp\x{0131}n\x{0308}al Tap"; say scalar reverse $band; # paT länıpS say grapheme_reverse($band); # paT lan̈ıpS
This module provides Unicode grapheme cluster–level versions of Perl’s built-in string functions, tailored to work on grapheme clusters as opposed to code points or bytes.
This is an early release and major revisions are planned for the near future.
Functions may each be exported explicitly or by using the :all tag for everything.
:all
Returns the length of the given string in grapheme clusters. This is the closest to the number of “characters” that many people would count on a printed string.
Returns the given string with the last grapheme cluster chopped off. Does not modify the original value, unlike the built-in chop.
chop
Returns the given string value with all grapheme clusters in the opposite order.
grapheme_substr, graphem_index, grapheme_rindex, canonical_eq, compatibility_eq
grapheme_substr
graphem_index
grapheme_rindex
canonical_eq
compatibility_eq
Unicode::GCString, String::Multibyte, Perl6::Str, http://perlcabal.org/syn/S32/Str.html
Nick Patch <patch@cpan.org>
© 2011–2013 Nick Patch
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Unicode::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Unicode::Util
CPAN shell
perl -MCPAN -e shell install Unicode::Util
For more information on module installation, please visit the detailed CPAN module installation guide.