GSP
Quick Navigator

Search Site

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

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Tickit::StringPos(3) User Contributed Perl Documentation Tickit::StringPos(3)

"Tickit::StringPos" - store string position counters

 use Tickit::StringPos;
 use Tickit::Utils qw( string_count );

 my $pos = Tickit::StringPos->zero;
 string_count( "Here is a message", $pos );

 print "The message consumes ", $pos->columns, " columns\n";

Instances in this object class store four position counters that relate to counting strings.

The "bytes" member counts UTF-8 bytes which encode individual codepoints. For example the Unicode character U+00E9 is encoded by two bytes 0xc3, 0xa9; it would increment the bytes counter by 2 and the "codepoints" counter by 1.

The "codepoints" member counts individual Unicode codepoints.

The "graphemes" member counts whole composed graphical clusters of codepoints, where combining accents which count as individual codepoints do not count as separate graphemes. For example, the codepoint sequence U+0065 U+0301 would increment the "codepoint" counter by 2 and the "graphemes" counter by 1.

The "columns" member counts the number of screen columns consumed by the graphemes. Most graphemes consume only 1 column, but some are defined in Unicode to consume 2.

Instances are also used to store count limits, where any memeber may be set to -1 to indicate no limit in that counter.

   $pos = Tickit::StringPos->zero

Returns a new instance with all counters set to zero.

   $pos = Tickit::StringPos->limit_bytes( $bytes )

   $pos = Tickit::StringPos->limit_codepoints( $codepoints )

   $pos = Tickit::StringPos->limit_graphemes( $graphemes )

   $pos = Tickit::StringPos->limit_columns( $columns )

Return a new instance with one counter set to the given limit and the other three counters set to -1.

   $bytes = $pos->bytes

   $codepoints = $pos->codepoints

   $graphemes = $pos->graphemes

   $columns = $pos->columns

Return the current value the counters.

Paul Evans <leonerd@leonerd.org.uk>
2022-04-07 perl v5.32.1

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

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