Skip Menu |

This queue is for tickets about the Text-Table CPAN distribution.

Report information
The Basics
Id: 127992
Status: open
Priority: 0/
Queue: Text-Table

People
Owner: Nobody in particular
Requestors: jhouser [...] hsp.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug in Text::Table
Date: Tue, 11 Dec 2018 16:11:00 +0000
To: "bug-Text-Table [...] rt.cpan.org" <bug-Text-Table [...] rt.cpan.org>
From: John Houser <jhouser [...] hsp.org>
I’m using Text::Table to create a report from a database containing UTF-8 characters. (See version information below.) Unfortunately, Text::Table doesn’t count characters correctly when the contents of the table includes UTF-8 multi-byte characters (such as a character with an accent). It would be good to have a UTF-8 mode, or at least a warning in the documentation that the module may not work correctly with this kind of data. Module id = Text::Table CPAN_USERID SHLOMIF (Shlomi Fish <shlomif@shlomifish.org>) CPAN_VERSION 1.133 CPAN_FILE S/SH/SHLOMIF/Text-Table-1.133.tar.gz UPLOAD_DATE 2017-08-04 MANPAGE Text::Table - Organize Data in Tables INST_FILE /usr/local/share/perl/5.20.2/Text/Table.pm INST_VERSION 1.133 -- John Houser Chief Information Officer 1300 Locust Street Philadelphia, PA 19107 jhouser@hsp.org<mailto:jhouser@hsp.org> 215-732-6200 x218 [id:image001.png@01D33B9F.F7FDCA80]
Download image001.png
image/png 15.3k
image001.png
Subject: [rt.cpan.org #127992] Bug in Text::Table
Date: Sun, 18 Aug 2019 06:38:23 +0000
To: "bug-Text-Table [...] rt.cpan.org" <bug-Text-Table [...] rt.cpan.org>
From: Stephan Hradek <stephan.hradek [...] eco.de>
Hi! That's not a bug I think, that's how perl works. Put this at the top of your script and everything should be fine: use utf8; use open qw/:std :utf8/; See perldoc open for details. I've tested with use strict; use warnings; use utf8; use open qw/:std :utf8/; use Text::Table; my $tb= Text::Table->new( { title => 'left' }, \' | ', { title => 'right', align => 'right' }); $tb->add('äää','äää'); $tb->add('a','a'); print $tb; Try the different outputs when you remove "use utf8" or the "ues open…". Stephan Hradek
Download smime.p7s
application/pkcs7-signature 2.4k

Message body not shown because it is not plain text.

On Tue Dec 11 11:11:17 2018, jhouser@hsp.org wrote: Show quoted text
> I’m using Text::Table to create a report from a database containing > UTF-8 characters. (See version information below.) Unfortunately, > Text::Table doesn’t count characters correctly when the contents of > the table includes UTF-8 multi-byte characters (such as a character > with an accent). It would be good to have a UTF-8 mode, or at least a > warning in the documentation that the module may not work correctly > with this kind of data. > > Module id = Text::Table > CPAN_USERID SHLOMIF (Shlomi Fish <shlomif@shlomifish.org>) > CPAN_VERSION 1.133 > CPAN_FILE S/SH/SHLOMIF/Text-Table-1.133.tar.gz > UPLOAD_DATE 2017-08-04 > MANPAGE Text::Table - Organize Data in Tables > INST_FILE /usr/local/share/perl/5.20.2/Text/Table.pm > INST_VERSION 1.133 > -- > John Houser > Chief Information Officer > 1300 Locust Street > Philadelphia, PA 19107 > jhouser@hsp.org<mailto:jhouser@hsp.org> > 215-732-6200 x218 > [id:image001.png@01D33B9F.F7FDCA80]
Hi Mr. Houser! Sorry for the late response. Can you share an example reproducing code? See: * https://github.com/shlomif/how-to-share-code-online * https://github.com/shlomif/writing-the-perfect-question Thanks!
Subject: Re: [rt.cpan.org #127992] Bug in Text::Table
Date: Sun, 18 Aug 2019 08:27:33 +0000
To: "bug-Text-Table [...] rt.cpan.org" <bug-Text-Table [...] rt.cpan.org>
From: Stephan Hradek <stephan.hradek [...] eco.de>
Hi Shlomi. Take my example. It'll clearly show the difference and - as I said - it's not a bug. With both "use" you'll get left | right äää | äää a | a with none you get left | right äää | äää a | a with just "use utf8" you'll get left | right ��� | ��� a | a ans with just "use open qw/:std :utf8/;" you'll get left | right äää | äää a | a Hope that helps. -- stephan
Download smime.p7s
application/pkcs7-signature 2.4k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #127992] Bug in Text::Table
Date: Wed, 18 Sep 2019 05:48:16 +0000
To: "bug-Text-Table [...] rt.cpan.org" <bug-Text-Table [...] rt.cpan.org>
From: Stephan Hradek <stephan.hradek [...] eco.de>
I have to correct myself Just yesterday I did the same as the OP: Receive UTF-8 encoded text from a mysql DB. Printing it with Text::Table miserably fails. When I just print them, aligning goes wrong. When I follow my own advice it seems as if perl encodes an already UTF-8 encoded string again. Aligning then works, but the string is garbled. Stephan Hradek Show quoted text
> Am 18.08.2019 um 08:38 schrieb Stephan Hradek <stephan.hradek@eco.de>: > > Hi! > > That's not a bug I think, that's how perl works. > > Put this at the top of your script and everything should be fine: > > use utf8; > use open qw/:std :utf8/; > > See perldoc open for details. > > > I've tested with > > use strict; > use warnings; > use utf8; > use open qw/:std :utf8/; > use Text::Table; > > my $tb= Text::Table->new( { title => 'left' }, \' | ', { title => 'right', align => 'right' }); > $tb->add('äää','äää'); > $tb->add('a','a'); > print $tb; > > Try the different outputs when you remove "use utf8" or the "ues open…". > > Stephan Hradek >
Download smime.p7s
application/pkcs7-signature 2.4k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #127992] Bug in Text::Table
Date: Wed, 18 Sep 2019 06:48:33 +0000
To: "bug-Text-Table [...] rt.cpan.org" <bug-Text-Table [...] rt.cpan.org>
From: Stephan Hradek <stephan.hradek [...] eco.de>
Update… It's easily fixed. Text::Table only handles "Perl Strings". So before adding a string to a table, do a decode('UTF-8', $string) Stephan Hradek Show quoted text
> Am 18.09.2019 um 07:48 schrieb Stephan Hradek <stephan.hradek@eco.de>: > > I have to correct myself > > Just yesterday I did the same as the OP: Receive UTF-8 encoded text from a mysql DB. > > Printing it with Text::Table miserably fails. > > When I just print them, aligning goes wrong. > > When I follow my own advice it seems as if perl encodes an already UTF-8 encoded string again. Aligning then works, but the string is garbled. > > Stephan Hradek > > >
>> Am 18.08.2019 um 08:38 schrieb Stephan Hradek <stephan.hradek@eco.de <mailto:stephan.hradek@eco.de>>: >> >> Hi! >> >> That's not a bug I think, that's how perl works. >> >> Put this at the top of your script and everything should be fine: >> >> use utf8; >> use open qw/:std :utf8/; >> >> See perldoc open for details. >> >> >> I've tested with >> >> use strict; >> use warnings; >> use utf8; >> use open qw/:std :utf8/; >> use Text::Table; >> >> my $tb= Text::Table->new( { title => 'left' }, \' | ', { title => 'right', align => 'right' }); >> $tb->add('äää','äää'); >> $tb->add('a','a'); >> print $tb; >> >> Try the different outputs when you remove "use utf8" or the "ues open…". >> >> Stephan Hradek >>
>
Download smime.p7s
application/pkcs7-signature 2.4k

Message body not shown because it is not plain text.