Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

text::charwidth(3pm) [debian man page]

CharWidth(3pm)						User Contributed Perl Documentation					    CharWidth(3pm)

NAME
Text::CharWidth - Get number of occupied columns of a string on terminal SYNOPSIS
use Text::CharWidth qw(mbwidth mbswidth mblen); mbwidth(string); mbswidth(string); mblen(string); DESCRIPTION
This module supplies features similar as wcwidth(3) and wcswidth(3) in C language. Characters have its own width on terminal depending on locale. For example, ASCII characters occupy one column per character, east Asian fullwidth characters (like Hiragana or Han Ideograph) occupy two columns per character, and combining characters (apperaring in ISO-8859-11 Thai, Unicode, and so on) occupy zero columns per character. mbwidth() gives the width of the first character of the given string and mbswidth() gives the width of the whole given string. The names of mbwidth and mbswidth came from "multibyte" versions of wcwidth and wcswidth which are "wide character" versions. mblen(string) returns number of bytes of the first character of the string. Please note that a character may consist of multiple bytes in multibyte encodings such as UTF-8, EUC-JP, EUC-KR, GB2312, or Big5. mbwidth(string) returns the width of the first character of the string. mbswidth(string) returns the width of the whole string. Parameters are to be given in locale encodings, not always in UTF-8. SEE ALSO
locale(5), wcwidth(3), wcswidth(3) AUTHOR
Tomohiro KUBOTA, <kubota@debian.org> COPYRIGHT AND LICENSE
Copyright 2003 by Tomohiro KUBOTA This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2003-06-25 CharWidth(3pm)

Check Out this Related Man Page

wcswidth(3)						     Library Functions Manual						       wcswidth(3)

NAME
wcswidth - Determines the display width of wide-character strings LIBRARY
Standard C Library (libc) SYNOPSIS
#include <wchar.h> int wcswidth( const wchar_t *pwcs, size_t n); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: wcswidth(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Contains a pointer to the wide-character string. Specifies the maximum number of wide characters whose display width is to be determined. DESCRIPTION
The wcswidth() function determines the number of display columns to be occupied by the number of wide characters specified by the n parame- ter in the string pointed to by the pwcs parameter. The behavior of the wcswidth() function is affected by the LC_CTYPE category. Fewer than the number of wide characters specified by the n parameter are counted if a null wide character is encountered first. EXAMPLES
The following example finds the display column width of a wide-character string: #include <wchar.h> #include <locale.h> main() { wchar_t *pwcs; int retval, n ; (void)setlocale(LC_ALL, ""); /* Let pwcs point to a wide-character null-terminated ** string. Let n be the number of wide characters whose ** display column width is to be determined. */ retval= wcswidth( pwcs, n ); if(retval == -1){ /* Error handling. Invalid wide-character code ** encountered in the wide-character string pwcs. */ } } RETURN VALUES
The wcswidth() function returns the number of display columns to be occupied by the specified number of wide characters or (if a null wide character is encountered first) by the number of wide characters encountered before the null. The function returns a value of 0 (zero) if the pwcs parameter is a null pointer or a pointer to a null pointer (that is, if either pwcs or *pwcs is null. The function returns -1 if the pwcs parameter points to a nonprinting wide character. RELATED INFORMATION
Functions: mblen(3), wcslen(3), wcwidth(3) Standards: standards(5) delim off wcswidth(3)
Man Page