Re: ANNOUNCE: Text::CSV_XS 0.32



Mumia W. wrote:
On 10/24/2007 11:59 PM, Petr Vileta wrote:
Well, I'm pleased to see you here :-)
I tried to use your module Text::CSV_XS for storing some data to CSV
file but without success. The problem is national characters. When I
tried $csv->combine(('abc',áíá','def') I got "abc\n" only. Your
module fail on first field where something greather then \x7f is.
But no error, no warning.
Is this a bug or feature?


This sort-of works for me:

#!/usr/bin/perl
use strict;
use warnings;
use encoding 'iso-8859-1';
use Text::CSV_XS 0.32;

print "Version = $Text::CSV_XS::VERSION\n";

my $csv = Text::CSV_XS->new({binary => 1});

I suppose that binari is intended for "unprintable" characters.


However, the output seems to be forced to UTF-8:


I can't to use utf-8, I must use iso-8859-1 for some reason.

So Text::CSV_XS seems to ignore both the script encoding and the
locale. I had set LANG=en_US.ISO-8859-1 in Linux before running the
script.

Hmm, ignore but not thoroughly :-) I avoid using combine() finction by this sub

sub mycombine
{
my @fileds=@_;
my $line = '';
foreach (@fileds)
{
s/\"/\"\"/g;
$line .= '"' . $_ . '"';
}
$line .= chr(13) . $chr(10);
return $line;
}

Ys, of course, this not look to filed type (number or string) but for my intention this is sufficient. This work with program and locales settings. Maybe will be good to add some functions to your module to set up input and output codepages. Some like
$csv = $csv = Text::CSV_XS->new('input_charser' => 'utf-8', 'output_charset => 'iso-8859-1');
But this is my idea only ;-)
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail from another non-spammer site please.)


.



Relevant Pages

  • Re: Is IoStatus.Status reliable?
    ... > I take it you were thinking of informational type messages not warning? ... The status is what the lower driver provided (I'm assuming drivers ... NT_SUCCSS returns true for either SUCCESS or WARNING class messages, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: %DCL-W-OKTAB again...
    ... >f$messageand exit 261440 which does change the ... webserver doesn't do any attempts to modify the DCL tables. ... success message and translates it into a warning. ...
    (comp.os.vms)
  • Re: returning an HRESULT that represents a warning
    ... That's the convention for internal NT codes. ... errors and success (warnings and info results are considered ... This would indicate that an error and a warning are both errors. ... HRESULT are either success or fail. ...
    (microsoft.public.vc.atl)
  • RE: How to delete a Non valid Office Addin
    ... I looked and tried but no success. ... valid Office add-in. ... >> warning is shown that I have an Addin that is not valid for Office. ...
    (microsoft.public.word.docmanagement)