views:

114

answers:

2

Hello! Is "'|-:encoding(utf-8)'" in "open my $column, '|-:encoding(utf-8)', qw(column);" ok? It seems to work almost. In the row with the "Mikołaj" the formatting is not correct; how can I fix it?

#!/usr/bin/perl
use warnings;
use strict;
use utf8;
binmode STDOUT, ':encoding(utf-8)';
# edit:
binmode DATA, ':encoding(utf-8)';

open my $column, '|-:encoding(utf-8)', qw(column);
print $column "$_\n" for <DATA>;

__DATA__
Julius
Giovanni
George
Alonso
Jerome
Eugène
Reinhold
Gustav
Pavel
Franz
Max
Mikołaj
Maurice
Alec
Émile
Xaver
Henry
Wolfgang
Alexander
Enrico
Bedrich
Joaquín
Bartholomäus
Otto
Carl
Isaak
Anatol
Leos
Herbert
Paul
Benjamin
Matthew
Jean
+1  A: 

This example script works correctly for me in BSD/OSX. Usually when there's an issue with formatting it's an encoding mismatch somewhere. Make sure:

  • the file is being saved in UTF8 format (check whatever text editor you're using)
  • your terminal handles UTF8 (view the file in the terminal, should appear correctly)
Ben
My text editor and my terminal is set to utf-8.
sid_com
+2  A: 

You talk about formatting and evidently want aligned output. I notice that ł is the only character in the sample not occurring in Latin1. To rule out the problem that you just have a stupid font, configure your terminal to display a well-behaved one with extensive coverage: DejaVu Sans Mono is nice.

Also, have you hexdumped the output yet? This is what I get:

0000  4d 69 6b 6f c5 82 61 6a  0a                       Miko..aj .
daxim
Thx, I changed the font, and now it works fine.
sid_com