in reply to Re: Text::Wrap and non-Roman languages
in thread Text::Wrap and non-Roman languages

Thanks - I overlooked that one. A brief test, with zwon's code, and it looks like it works. As long as I don't "use utf8;" or use -CS on the commandline. I'm not sure why... I suppose because the input I got wasn't actually utf8, but I don't know what else it could be when it's displaying fine here :-) (And konsole thinks that the encoding it's using is UTF-8, and LANG is set to en_US.utf8...) So I'm just confused as to why explicitly marking things as utf8 is breaking it.

I'm sure that'll be a question for the future.

Replies are listed 'Best First'.
Re^3: Text::Wrap and non-Roman languages
by zwon (Abbot) on Jan 10, 2010 at 17:16 UTC

    For me it works with use utf8 but issues the warnings:

    substr outside of string at /usr/share/perl5/Text/WrapI18N.pm line 130 +. Use of uninitialized value $text in length at /usr/share/perl5/Text/Wr +apI18N.pm line 52.

    Update: after investigating a bit more I also found Text::LineFold, it looks like it does the right thing, though it also ignores utf8 flag on strings.

    use strict; use warnings; use 5.010; use utf8; use open ':std', ':utf8'; use Text::LineFold; my $lf = Text::LineFold->new( ColumnsMax => 12, ); while (<>) { my $folded = $lf->fold($_); utf8::decode($folded); say $folded; }