Text::WrapI18N - Line wrapping module with support for multibyte, fullwidth, and combining characters and languages without whitespaces between words
| Use Case | Command | Description |
|---|---|---|
| 🔤 Wrap text with multibyte support | use Text::WrapI18N qw(wrap $columns); wrap('', '', $text); | 🔄 Wraps $text using current locale encoding, supporting UTF-8, East Asian, etc. |
| 📏 Set custom line width | $Text::WrapI18N::columns = 72; | 📐 Changes default column width (default 76) for wrapping. |
| 📝 Wrap with headers | wrap("Header: ", " ", $long_text); | 📌 First line gets firstheader, subsequent lines get nextheader prefix. |
| 🌐 Handle CJK without spaces | wrap('', '', $chinese_text); | 🇨🇳 Module attempts minimal handling of languages without whitespace between words. |
use Text::WrapI18N qw(wrap $columns);
wrap(firstheader, nextheader, texts);
This module intends to be a better Text::Wrap module. This module is needed to support multibyte character encodings such as UTF-8, EUC-JP, EUC-KR, GB2312, and Big5. This module also supports characters with irregular widths, such as combining characters (which occupy zero columns on terminal, like diacritical marks in UTF-8) and fullwidth characters (which occupy two columns on terminal, like most of east Asian characters). Also, minimal handling of languages which doesn't use whitespaces between words (like Chinese and Japanese) is supported.
Like Text::Wrap, hyphenation and "kinsoku" processing are not supported, to keep simplicity.
wrap(firstheader, nextheader, texts) is the main subroutine of Text::WrapI18N module to execute the line wrapping. Input parameters and output data emulate Text::Wrap. The texts have to be written in locale encoding.
Tomohiro KUBOTA, <kubota AT debian.org>
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.
Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-21 19:18 @216.73.217.134
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)