vsespb has asked for the wisdom of the Perl Monks concerning the following question:
printsuse strict; use warnings; use Text::CSV; use Data::Dumper; use Devel::Peek; open my $f, ">", "test.tmp"; print $f "\xD0\x81"; close $f; open my $io, "<", "test.tmp" or die "$!"; my $csv = Text::CSV->new ({ binary => 1, eol => "\012" }); while (my $row = $csv->getline ($io)) { print Dumper $row; Dump $row; }
that means it interprets input as UTF-8 data and parses it to perl character string$VAR1 = [ "\x{401}" ]; SV = IV(0x245c998) at 0x245c9a8 REFCNT = 1 FLAGS = (PADMY,ROK) RV = 0x2550980 SV = PVAV(0x23f49b8) at 0x2550980 REFCNT = 2 FLAGS = () ARRAY = 0x24bdab0 FILL = 0 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL) Elt No. 0 SV = PV(0x23f22a0) at 0x2412470 REFCNT = 1 FLAGS = (POK,pPOK,UTF8) PV = 0x260e200 "\320\201"\0 [UTF8 "\x{401}"] CUR = 2 LEN = 16
On parsing (both for getline () and parse ()), if the source is marked being UTF8, then all fields that are marked binary will also be be marked UTF8.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Text::CSV and Unicode
by Tux (Canon) on Nov 11, 2013 at 10:45 UTC | |
by vsespb (Chaplain) on Nov 11, 2013 at 11:00 UTC | |
by Jim (Curate) on Nov 11, 2013 at 17:59 UTC | |
by Anonymous Monk on Nov 11, 2015 at 15:09 UTC | |
|
Re: Text::CSV and Unicode
by Jim (Curate) on Nov 11, 2013 at 17:57 UTC |