CharWidth(3)
β¨ NAME β¨
Text::CharWidth β Get number of occupied columns of a string on terminal.
okay bestie, this is CharWidth(3) from the User Contributed Perl Documentation crew, and itβs all about Text::CharWidth β the Perl module that tells you how many terminal columns a string is lowkey occupying. π
β¨
π«Ά SYNOPSIS π«Ά
you import it like this, no cap:
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 their own width on a 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 (appearing 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. iykyk. π
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 asUTF-8,EUC-JP,EUC-KR,GB2312, orBig5. π§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. That part is important, bestie β do not assume UTF-8 every single time. π
π SEE ALSO π
locale(5), wcwidth(3), wcswidth(3) β these are the next besties to go check out. π
πΈ AUTHOR πΈ
Tomohiro KUBOTA, <kubota@debian.org> β author icon behavior. ππ
π 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. π«Άβ¨
π cute little source/version + date sign-off: perl v5.42.0, 2011-11-18, CharWidth(3) β mwah, bye bestie! ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Text-CharWidth 0.04-160000.84.2 Β· Artistic-1.0
- opensuse-leap 16.0: perl-Text-CharWidth 0.04-160000.84.2 Β· Artistic-1.0
- opensuse-leap 16.0: perl-Text-CharWidth 0.04-160000.84.2 Β· Artistic-1.0
- opensuse-leap 16.0: perl-Text-CharWidth 0.04-160000.84.2 Β· Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms