Text-CSV-Unicode-0.400000755000000000000 013354670707 15021 5ustar00unknownunknown000000000000Text-CSV-Unicode-0.400/Build.PL000444000000000000 46113354426204 16422 0ustar00unknownunknown000000000000use Module::Build; Module::Build->new( module_name => 'Text::CSV::Unicode', configure_requires => { Module::Build => 0.38 }, requires => { perl => 5.008, Text::CSV => 1, }, build_requires => { Test::More => 0 }, license => 'perl', create_makefile_pl => 'traditional', ) -> create_build_script; Text-CSV-Unicode-0.400/Changes000444000000000000 615013354654052 16446 0ustar00unknownunknown000000000000Revision history for Perl extension Text::CSV::Unicode. 0.01 Tue Jul 10 14:21:57 2007 - original version; created from my locally modified Text::CSV 0.02 2007-07-19 - fix use of C< binary => 1 > in POD - added requires => { perl => 5.008 } to Build.PL 0.03 2007-07-24 - Add C to Makefile.PL to prevent test failures 0.04 2007-08-08 - two typos in lib/Text/CSV/Unicode.pm, and hide URL - skip_all tests in t/1.t if not perl v5.8.0 or Text::CSV 0.05 2007-09-25 - use import to check Text::CSV 0.01 not the "UNAUTHORIZED RELEASE" - use a variable for \N{QUOTATION MARK} in strings and regexp 0.06 2007-12-30 - remove inc/Module/Build/Compat.pm: functionality now in release - reinstate C: warnings clean for perl 5.10.0 **** Release of Text::CSV 1.00 (November 2007) broke 0.06 0.099 2007-12-31 - Text::CSV::Base to substitute for Text::CSV 0.01 0.100 2007-12-31 - more documentation from Text::CSV - documentation of the inclusion of lib/Text/CSV/Base.pm t/base.t 0.110 2008-01-01 - use {_CHAROK} in combine - fix Text::CSV::Unicode->version - fix documentation of allowable characters in CAVEATS 0.111 2008-04-08 Changes to improve kwalitee - Build.PL not executable - added C to Text::CSV::Base - added Test::More to build_requires - added examples/ 0.112 2010-02-17 Change to _CHAROK due to changes to unicode properties in perl 5.11.4 0.113 2011-08-24 Update Text/CSV/Base.pm to version 0.041 Add t/combine-undef.t - avoid warnings on undef values in input array to combine 0.114 2012-02-06 Some testers were failing with C type failures in the test scripts, despite no C - add and make the test scripts strict 0.115 2012-02-19 perl 5.15.5 fails due to faulty installation: put in explicit require/skip_all for charnames 0.200 2018-09-21 Completely rewritten to use Text::CSV Allow unicode but not Cntrl in Text::CSV::Unicode Allow all unicode with binary=>1, by dropping through to Text::CSV combine() with undef produces different output: t/combine-undef.t version() provided by Text::CSV::Version - test as class method: t/unicode.t 0.200_001 2018-09-21 22:00 Attempt to avoid t/unicode.t failures on perl 5.16 0.200_004 2018-09-24 15:00 Explicit C in t/unicode.t for 'deprecated' test 0.201 2018-09-25 Add C to t/unicode.t: deprecate was not a default warning before perl 5.18.0, so the 'deprecated' test had been failing on earlier perls. Use C Better punctuation in the t/unicode.t tests 0.299_001 2018-09-27 Text::CSV::Base is redundant Document always_quote in Text::CSV::Unicode Drop charnames - not used 0.300 2018-09-28 Text::CSV::Unicode does not use Text::CSV::Base Text::CSV::Base is redundant Text::CSV::Unicode does not set C 1> Text::CSV::Unicode C 1> is deprecated 0.399_001 2018-09-27 Removed Text::CSV::Base t/base.t tests Text::CSV::Base as 'empty subclass' 0.399_002 2018-10-01 Replace C with C 0.400 2018-10-02 Removed Text::CSV::Base - except from tests Text-CSV-Unicode-0.400/MANIFEST000444000000000000 61213354670620 16260 0ustar00unknownunknown000000000000README MANIFEST Changes examples/combine.pl examples/parse.pl lib/Text/CSV/Unicode.pm Build.PL Makefile.PL Created by Module::Build t/base.t t/combine-undef.t t/pod-coverage.t t/pod.t t/unicode.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Text-CSV-Unicode-0.400/META.json000444000000000000 214413354670707 16600 0ustar00unknownunknown000000000000{ "abstract" : "comma-separated values manipulation routines", "author" : [ "Robin Barker " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.422", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Text-CSV-Unicode", "prereqs" : { "build" : { "requires" : { "Test::More" : "0" } }, "configure" : { "requires" : { "Module::Build" : "0.38" } }, "runtime" : { "requires" : { "Text::CSV" : "1", "perl" : "5.008" } } }, "provides" : { "Text::CSV::Unicode" : { "file" : "lib/Text/CSV/Unicode.pm", "version" : "0.400" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "version" : "0.400", "x_serialization_backend" : "JSON::PP version 2.27400" } Text-CSV-Unicode-0.400/META.yml000444000000000000 127313354670707 16432 0ustar00unknownunknown000000000000--- abstract: 'comma-separated values manipulation routines' author: - 'Robin Barker ' build_requires: Test::More: '0' configure_requires: Module::Build: '0.38' dynamic_config: 1 generated_by: 'Module::Build version 0.422, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Text-CSV-Unicode provides: Text::CSV::Unicode: file: lib/Text/CSV/Unicode.pm version: '0.400' requires: Text::CSV: '1' perl: '5.008' resources: license: http://dev.perl.org/licenses/ version: '0.400' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Text-CSV-Unicode-0.400/Makefile.PL000444000000000000 63613354670707 17115 0ustar00unknownunknown000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.4220 require 5.008; use ExtUtils::MakeMaker; WriteMakefile ( 'EXE_FILES' => [], 'NAME' => 'Text::CSV::Unicode', 'PL_FILES' => {}, 'PREREQ_PM' => { 'Test::More' => 0, 'Text::CSV' => 1 }, 'VERSION_FROM' => 'lib/Text/CSV/Unicode.pm', 'INSTALLDIRS' => 'site' ) ; Text-CSV-Unicode-0.400/README000444000000000000 345213354654430 16035 0ustar00unknownunknown000000000000Module: Text::CSV::Unicode Description: Text::CSV::Unicode builds on Text::CSV to provides facilities for the composition and decomposition of comma-separated values. Text::CSV::Unicode handles input that includes 8-bit (and more) data. It is based on version 0.01 of Text::CSV, but has been reimplemented to use the current Text::CSV. Copying: Copyright (c) 2007, 2008, 2010, 2011, 2012, 2018 Robin Barker. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. lib/Text/CSV/Base.pm (version 0.01) was a direct copy of Text-CSV-0.01/CSV.pm, and t/base.t was a direct copy of Text-CSV-0.01/test.pl, with only the module name changed (and white-space changes), and these files are Copyright (c) 1997 Alan Citterman. Author: Robin Barker based on Text::CSV by Alan Citterman Prerequisites: perl 5.8.0 Build/Installation: Standard build/installation supported by ExtUtils::MakeMaker(3)... perl Makefile.PL make make test make install Recent Changes: v0.400 2018-10-02 Removed Base.pm base.t tests empty Text::CSV::Base class Refactored Unicode.pm v0.300 2018-09-28 Text::CSV::Unicode does not use Text::CSV::Base Text::CSV::Base is redundant Text::CSV::Unicode does not set C 1> Text::CSV::Unicode C 1> is deprecated v0.201 2018-09-25 Add C to t/unicode.t: deprecate was not a default warning before perl 5.18.0, so the 'deprecated' test had been failing on earlier perls. v0.200 2018-09-21 Completely rewritten to use Text::CSV Allow unicode but not Cntrl in Text::CSV::Unicode Allow all unicode with binary=>1, by dropping through to Text::CSV Text-CSV-Unicode-0.400/examples000755000000000000 013354670707 16637 5ustar00unknownunknown000000000000Text-CSV-Unicode-0.400/examples/combine.pl000444000000000000 74213354426204 20717 0ustar00unknownunknown000000000000use strict; use Text::CSV::Unicode; my $csv = Text::CSV::Unicode->new; my @data = ( [qw( Author Organisation Count Comment)], [ 'Robin Barker', 'NPL', 1, 'This is a short comment' ], [ 'Chris Williams', 'NPL', 0, 'This is a comment with ooo!' ], [ 'Mr Sand', 'Justervesenet', -1 ], [ 'Walter Raleigh', 'PTB', 100, '"no comment"' ] ); local $\ = "\n"; for my $data (@data) { $csv->combine(@$data) or die $csv->error_input; print $csv->string; } Text-CSV-Unicode-0.400/examples/parse.pl000444000000000000 104513354426204 20432 0ustar00unknownunknown000000000000use strict; use Text::CSV::Unicode; my $csv = Text::CSV::Unicode->new(); my @data; while( ) { while( tr/"/"/ % 2 and my $line = ) { $_ .= $line } $csv -> parse($_) or die $csv->error_input; push @data, [$csv->fields]; } use Data::Dumper; print Dumper(\@data); __END__ Author,Organisation,Count,Comment Robin Barker,NPL,1,"This is a short comment" Chris Eiø,NPL,0,"This is a comment with o's ÒÓÔÕÖØðòóôõö" Åsmund Sand,Justervesenet,-1,"This is a long comment split over two lines" Walter Wöger,PTB,100,"""no comment""" Text-CSV-Unicode-0.400/lib000755000000000000 013354670707 15567 5ustar00unknownunknown000000000000Text-CSV-Unicode-0.400/lib/Text000755000000000000 013354670707 16513 5ustar00unknownunknown000000000000Text-CSV-Unicode-0.400/lib/Text/CSV000755000000000000 013354670707 17146 5ustar00unknownunknown000000000000Text-CSV-Unicode-0.400/lib/Text/CSV/Unicode.pm000444000000000000 1030513354670362 21243 0ustar00unknownunknown000000000000package Text::CSV::Unicode; use strict; use warnings; use base qw(Text::CSV); our $VERSION = '0.400'; sub new { my ($self, $hash) = @_; if ( $hash and $hash -> {binary} ) { warnings::warnif("deprecated", "binary is deprecated: use Text::CSV"); return Text::CSV->new( $hash ); } return $self->SUPER::new( { binary => 1, %{ $hash || {} } } ); } sub combine { my $self = shift; for (grep defined, @_) { return if _bad(); } return $self->SUPER::combine(@_); } sub parse { my $self = shift; for (map +$_, grep defined, @_) { chomp; return if _bad(); } return $self->SUPER::parse( @_ ); } sub _bad { m{ [^\t\P{Cntrl}] }x; } # test $_ 1; __END__ =head1 NAME Text::CSV::Unicode - comma-separated values manipulation routines with potentially wide character data =head1 SYNOPSIS use Text::CSV::Unicode; $csv = Text::CSV::Unicode->new(); # then use methods from Text::CSV $version = Text::CSV::Unicode->VERSION(); # get the module version $csv = Text::CSV::Unicode->new(); # create a new object $status = $csv->combine(@columns); # combine columns into a string $line = $csv->string(); # get the combined string $status = $csv->parse($line); # parse a CSV string into fields @columns = $csv->fields(); # get the parsed fields $status = $csv->status(); # get the most recent status $bad_argument = $csv->error_input();# get the most recent bad argument =head1 DESCRIPTION Text::CSV::Unicode provides facilities for the composition and decomposition of comma-separated values, based on Text::CSV. Text::CSV::Unicode allows for input with wide character data but does not permit control characters. =head1 Incompatible Changes =head2 Option always_quote=>1 (v0.300) Before v0.300, the module behaviour defaulted to C<< always_quote => 1 >> in Text::CSV. This behaviour was only needed in tests. To recreate the old behaviour: $csv = Text::CSV::Unicode->new( { always_quote => 1 } ); =head1 DEPRECATED The option C<< binary => 1 >> does not require this module. This code issues a 'deprecated' warning and creates a Text::CSV object: $csv = Text::CSV::Unicode->new( { binary => 1 } ); =head1 METHODS =over 4 =item VERSION This function may be called as a class or an object method. As a class method, it returns the currrent module version. As an object method, it returns the version of the underlying Text::CSV module. =item version An object method: it returns the backend module version. =item new $csv = Text::CSV::Unicode->new( [{ binary => 1 }] ); This function may be called as a class method. It returns a reference to a newly created object. C<< binary => 0 >> allows the same ASCII input as Text::CSV. C<< binary => 1 >> allows for all Unicode characters in the input (including \r and \n): the same functionality as C<< Text::CSV->new( { binary => 1 } >>. =item combine $status = $csv->combine(@columns); This object function constructs a CSV string from the arguments, returning success or failure. Failure can result from lack of arguments or an argument containing an invalid character. Silently accepts undef values in input and treats as an empty string. =item parse $status = $csv->parse($line); This object function decomposes a CSV string into fields, returning success or failure. Failure can result from a lack of argument or the given CSV string is improperly formatted. Upon failure, the value returned by C is undefined and C can be called to retrieve the invalid argument. =back =head1 DIAGNOSTICS None =head1 CONFIGURATION AND ENVIRONMENT See HASH option to C<< ->new >>. =head1 DEPENDENCIES perl 5.8.0 Text::CSV 1.0 =head1 VERSION 0.400 =head1 AUTHOR Robin Barker =head1 SEE ALSO Text::CSV =head1 LICENSE AND COPYRIGHT Copyright (c) 2007, 2008, 2010, 2011, 2012, 2018 Robin Barker. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The documentation of Text::CSV::Unicode methods that are inherited from Text::CSV is taken from Text::CSV 0.01 (with some reformatting) and is Copyright (c) 1997 Alan Citterman. =cut Text-CSV-Unicode-0.400/t000755000000000000 013354670707 15264 5ustar00unknownunknown000000000000Text-CSV-Unicode-0.400/t/base.t000444000000000000 650713354426204 16517 0ustar00unknownunknown000000000000# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) use strict; use warnings; my $loaded; BEGIN { $| = 1; print "1..20\n"; } END {print "not ok 1\n" unless $loaded;} use Text::CSV; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): # # Test non-existent package Text::CSV::Base # @Text::CSV::Base::ISA = qw(Text::CSV); # # empty subclass test # my $empty = Text::CSV::Base->new(); if ($empty->version() and $empty->parse('') and $empty->combine('')) { print "ok 2\n"; } else { print "not ok 2\n"; } my $csv = Text::CSV::Base->new( { always_quote => 1 } ); if (! $csv->combine()) { # fail - missing argument print "ok 3\n"; } else { print "not ok 3\n"; } if (! $csv->combine('abc', "def\n", 'ghi')) { # fail - bad character print "ok 4\n"; } else { print "not ok 4\n"; } if ($csv->combine('') && ($csv->string eq q(""))) { # succeed print "ok 5\n"; } else { print "not ok 5\n"; } if ($csv->combine('', '') && ($csv->string eq q("",""))) { # succeed print "ok 6\n"; } else { print "not ok 6\n"; } if ($csv->combine('', 'I said, "Hi!"', '') && ($csv->string eq q("","I said, ""Hi!""",""))) { # succeed print "ok 7\n"; } else { print "not ok 7\n"; } if ($csv->combine('"', 'abc') && ($csv->string eq q("""","abc"))) { # succeed print "ok 8\n"; } else { print "not ok 8\n"; } if ($csv->combine('abc', '"') && ($csv->string eq q("abc",""""))) { # succeed print "ok 9\n"; } else { print "not ok 9\n"; } if ($csv->combine('abc', 'def', 'ghi') && ($csv->string eq q("abc","def","ghi"))) { # succeed print "ok 10\n"; } else { print "not ok 10\n"; } if ($csv->combine("abc\tdef", 'ghi') && ($csv->string eq qq("abc\tdef","ghi"))) { # succeed print "ok 11\n"; } else { print "not ok 11\n"; } if (! $csv->parse()) { # fail - missing argument print "ok 12\n"; } else { print "not ok 12\n"; } if (! $csv->parse('"abc')) { # fail - missing closing double-quote print "ok 13\n"; } else { print "not ok 13\n"; } if (! $csv->parse('ab"c')) { # fail - double-quote outside of double-quotes print "ok 14\n"; } else { print "not ok 14\n"; } if (! $csv->parse('"ab"c"')) { # fail - bad character sequence print "ok 15\n"; } else { print "not ok 15\n"; } if (! $csv->parse(qq("abc\nc"))) { # fail - bad character print "ok 16\n"; } else { print "not ok 16\n"; } if (! $csv->status()) { # fail - test #16 should have failed print "ok 17\n"; } else { print "not ok 17\n"; } if ($csv->parse(q(",")) and ($csv->fields())[0] eq ',') { # success print "ok 18\n"; } else { print "not ok 18\n"; } if ($csv->parse(qq("","I said,\t""Hi!""","")) and ($csv->fields())[0] eq '' and ($csv->fields())[1] eq qq(I said,\t"Hi!") and ($csv->fields())[2] eq '') { # success print "ok 19\n"; } else { print "not ok 19\n"; } if ($csv->status()) { # success - test #19 should have succeeded print "ok 20\n"; } else { print "not ok 20\n"; } Text-CSV-Unicode-0.400/t/combine-undef.t000444000000000000 71613354426204 20274 0ustar00unknownunknown000000000000use strict; use warnings; use Test::More tests => 4; require_ok( q(Text::CSV::Unicode) ); my $warn = q{}; $SIG{__WARN__} = sub { $warn .= $_[0]; }; my @array; $array[1] = 'hello'; $array[3] = 'world'; my $csv = Text::CSV::Unicode->new( { always_quote => 1 } ); ok $csv->combine(@array), "combine with undef values"; is $csv->string, q{,"hello",,"world"}, "combine with undef values - output"; is $warn, q{}, "combine with undef values - no warnings"; Text-CSV-Unicode-0.400/t/pod-coverage.t000444000000000000 42213354426204 20126 0ustar00unknownunknown000000000000#!perl use strict; use warnings; use Test::More; eval{ require Test::Pod::Coverage; VERSION Test::Pod::Coverage 1.00; import Test::Pod::Coverage; }; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok(); Text-CSV-Unicode-0.400/t/pod.t000444000000000000 31513354426204 16336 0ustar00unknownunknown000000000000#!perl use strict; use warnings; use Test::More; eval{ require Test::Pod; VERSION Test::Pod 1.00; import Test::Pod; }; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Text-CSV-Unicode-0.400/t/unicode.t000444000000000000 741413354426204 17231 0ustar00unknownunknown000000000000# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl t/1.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use strict; use warnings; use Test::More tests => 32; BEGIN { use_ok('Text::CSV::Unicode') } my $tester=Test::More->builder; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $csv = Text::CSV::Unicode->new( { always_quote => 1 } ); ok (! $csv->combine(), 'fail - missing argument'); ok (! $csv->combine('abc', "def\n", 'ghi'), 'fail - bad character'); ok ($csv->combine('') && ($csv->string eq q("")), 'succeed'); ok ($csv->combine('', '') && ($csv->string eq q("","")), 'succeed'); ok ($csv->combine('', 'I said, "Hi!"', '') && ($csv->string eq q("","I said, ""Hi!""","")), 'succeed'); ok ($csv->combine('"', 'abc') && ($csv->string eq q("""","abc")), 'succeed'); ok ($csv->combine('abc', '"') && ($csv->string eq q("abc","""")), 'succeed'); ok ($csv->combine('abc', 'def', 'ghi') && ($csv->string eq q("abc","def","ghi")), 'succeed'); ok ($csv->combine("abc\tdef", 'ghi') && ($csv->string eq qq("abc\tdef","ghi")), 'succeed'); ok (! $csv->parse(), 'fail - missing argument'); ok (! $csv->parse('"abc'), 'fail - missing closing double-quote'); ok (! $csv->parse('ab"c'), 'fail - double-quote outside of double-quotes'); ok (! $csv->parse('"ab"c"'), 'fail - bad character sequence'); ok (! $csv->parse(qq("abc\nc")),'fail - bad character'); { my $test = $tester->current_test; ok (! $csv->status(), "fail - test $test should have failed"); } ok (($csv->parse(q(",")) and ($csv->fields())[0] eq ','), 'success'); ok (($csv->parse(qq("","I said,\t""Hi!""","")) and ($csv->fields())[0] eq '' and ($csv->fields())[1] eq qq(I said,\t"Hi!") and ($csv->fields())[2] eq ''), 'success'); { my $test = $tester->current_test; ok ($csv->status(), "success - test $test should have succeeded"); } ok( $csv->version(), 'inheritted version() works'); ok( $csv->isa('Text::CSV::Unicode'), 'creates a Text::CSV::Unicode object' ); my $warn; sub _warning(&) { my $sub = shift; local $SIG{__WARN__} = sub { $warn .= $_[0]; }; $warn = q{}; return $sub->(); } _warning { no warnings qw(deprecated); Text::CSV::Unicode->new( { binary => 1 } ) }; diag $warn if $warn; ok (!$warn, q(no 'deprecated' warning) ); my $csv1 = _warning { Text::CSV::Unicode->new( { binary => 1 } ) }; { my $warnok = $warn && $warn =~ /\bbinary\sis\sdeprecated\b/; diag( $warn || '(no warning)' ) unless $warnok; ok ( $warnok, q('binary is deprecated' warning) ); } ok ($csv1->parse(qq("abc\nc")), 'success - \n allowed'); { my $test = $tester->current_test; ok ($csv1->status(), "success - test $test should have succeeded"); } ok (($csv1->parse(qq("","I said,\n""Hi!""","")) and ($csv1->fields())[0] eq '' and ($csv1->fields())[1] eq qq(I said,\n"Hi!") and ($csv1->fields())[2] eq ''),'success - embedded \n'); { my $test = $tester->current_test; ok ($csv1->status(), "success - test $test should have succeeded"); } ok( $csv1->version(), 'inheritted version() works - binary`'); is( Text::CSV::Unicode->VERSION(), $Text::CSV::Unicode::VERSION, 'class version() works properly'); ok( !$csv1->isa('Text::CSV::Unicode'), 'binary=>1 does not create a Text::CSV::Unicode object' ); # # empty subclass test # @Text::CSV::Empty::ISA = qw(Text::CSV::Unicode); my $empty = Text::CSV::Empty->new(); ok (($empty->version() and $empty->parse('') and $empty->combine('')), 'empty subclass test'); ok( $empty->isa('Text::CSV::Unicode'), 'empty subclass creates a Text::CSV::Unicode object' );