Subject: | Feature Request: Read Control Codes < 0x20 |
Date: | Tue, 2 Dec 2014 15:51:36 -0600 |
To: | bug-Text-CSV_XS [...] rt.cpan.org |
From: | Brian Paterni <bpaterni [...] gmail.com> |
Hi
Thanks for resolving bug #99941
https://rt.cpan.org/Public/Bug/Display.html?id=99941
As I'm working to refactor Text::CSV_XS back into my project though, I
ran across another quoted fields problem. This time I can't seem to
get CSV_XS to stop quoting some fields...
The application I'm dealing with expects control characters < 0x20 in
some data fields. And even though Text::CSV_XS's documentation does
mention that it only accepts characters >= 0x20, running the data
through CSV_XS does seem to work to a degree, as these character do
seem to be printing in the output. The only problem is that CSV_XS is
detecting these characters as 'must-quote'-able characters and quotes
them on output even with quote_binary disabled. I've been reading and
re-reading the documentation to try and find a work around, but so far
I've coming up empty.
The following should be a basic test case. I would like to be able to
leave field 3 unquoted in the output if possible:
#!/bin/perl
use strict;
use warnings;
use Text::CSV_XS;
my $csv = Text::CSV_XS->new({
auto_diag => 1,
diag_verbose => 2,
binary => 1,
keep_meta_info => 11,
quote_space => 0,
quote_binary => 0,
# allow_loose_escapes => 1,
allow_loose_quotes => 1,
});
my $line = "Hello,World,\x13Field\x13With\x13Control\x13Chars";
print "input: $line\n";
$csv->parse($line);
my @flds = $csv->fields();
$csv->combine(@flds);
print 'output: ', $csv->string, "\n";