EXPORTS
Nothing per default, but can export the following per request:
:all
wcwidth
wcswidth
NAME
Termbox::Go::WCWidth - determine columns needed for a wide character
DESCRIPTION
This module is mainly for console/tty programs that carefully produce output for Terminals, or make pretend to be an emulator.
SYNOPSIS
sub print_right_aligned {
my ($s) = @_;
print " " x (80 - wcswidth($s));
say $s;
}
print_right_aligned("this is right-aligned");
print_right_aligned("another right-aligned string");
SUBROUTINES
wcwidth
Takes a single codepoint and outputs its width:
wcwidth(0x3042) # "あ" - returns 2
Returns:
-1for a control character0for a character that does not advance the cursor (NULL or combining)1for most characters2for full width characters
wcswidth
Takes a string and outputs its total width:
wcswidth("*ウルヰ*") # returns 8 = 2 + 6
Returns -1 if any control characters are found.
Unlike the Python version, this module does not support getting the width of only the first n characters of a string, as you can use the substr method.
COPYRIGHT AND LICENCE
This code was originally derived from C code with the name wcwidth.c.
Copyright (c) 2007 by Markus Kuhn
This library content was taken from the Terminal::WCWidth implementation of
Perl 6 which is licensed under MIT licence.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
AUTHORS
2015 by bluebear94 <tkook11@gmail.com>
2024,2025 by J. Schneider https://github.com/brickpool/
DISCLAIMER OF WARRANTIES
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.