Text-CSV-Encoded-0.25000755001750001750 012652374305 12542 5ustar00kdkd000000000000Changes100644001750001750 266312652374305 14125 0ustar00kdkd000000000000Text-CSV-Encoded-0.25Revision history for Perl extension Text::CSV::Encoded. 0.23 Sun Oct 4 12:44 2015 - Apply patch from https://rt.cpan.org/Ticket/Display.html?id=93438 - Doc fixes as per https://rt.cpan.org/Ticket/Display.html?id=89599 - Make dist metadata point to github and zarquon's fork 0.22 - Text::CSV 1.31 requierd in Makefile.PL (even works in minor version) 0.21 Thu Jun 13 14:31:12 2013 - Text::CSV 1.30 requierd in Makefile.PL (even works in minor version) 0.20 Wed Jun 12 13:18:02 2013 - update modules and test for Text::CSV_XS 0.99 and Text::CSV_PP 1.30 0.10 Mon Apr 26 17:41:12 2010 [Text::CSV::Encoded::Coder::*] - coder class can accept check value. ex. $csv->coder->encode_check_value( Encode::FB_PERLQQ ); $csv->coder->decode_check_value( Encode::FB_PERLQQ ); 0.09 Fri Oct 9 16:56:43 2009 - requires Text::CSV 1.12 or later. [Text::CSV::Encoded] - A construction fail returns undef (rt#46077) - improved new() section in the document [Text::CSV::Encoded::Coder::Encod] [Text::CSV::Encoded::Coder::EncodeGuess] - attr 'blank_is_undef' was not effective (reported by Zsombor Welker) 0.08 Thu Apr 23 15:23:42 2009 [Text::CSV::Encoded::Coder::EncodeGuess] - undef check before encode/decode (rt#45078) 0.07 Wed Oct 22 02:10:21 2008 - first release version [Text::CSV::Encoded] [Text::CSV::Encoded::Coder::Base] [Text::CSV::Encoded::Coder::Encode] [Text::CSV::Encoded::Coder::EncodeGuess] LICENSE100644001750001750 4371612652374305 13663 0ustar00kdkd000000000000Text-CSV-Encoded-0.25This software is copyright (c) 2016 by Makamaka Hannyaharamitu. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2016 by Makamaka Hannyaharamitu. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2016 by Makamaka Hannyaharamitu. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644001750001750 264212652374305 14273 0ustar00kdkd000000000000Text-CSV-Encoded-0.25name = Text-CSV-Encoded version = 0.25 author = Makamaka Hannyaharamitu, license = Perl_5 copyright_holder = Makamaka Hannyaharamitu [MinimumPerl] perl = 5.008 [GatherDir] [ManifestSkip] [MetaYAML] [MetaJSON] [License] [ExecDir] [ShareDir] [Manifest] [Test::Kwalitee::Extra] [TestRelease] [ConfirmRelease] [UploadToCPAN] [ReversionOnRelease] [MakeMaker::Awesome] test_file = t/*.t [@Git] [Prereqs] IO::Handle = 0 Test::More = 0 Test::Harness = 0 Text::CSV = 1.31 [PkgVersion] [PodVersion] [NextRelease] [ReadmeFromPod] type = pod [GithubMeta] issues = 1 user = singingfish repo = Text-CSV-Encoded [PodSyntaxTests] [Run::BeforeBuild] run = test ! -f Makefile.PL || rm Makefile.PL run = test ! -f META.yml || rm META.yml run = test ! -f META.json || rm META.json run = test ! -f MANIFEST || rm MANIFEST run = test ! -f README.pod || rm README.pod [Run::AfterBuild] run = cp %d/Makefile.PL ./ run = cp %d/README.pod ./ run = git status --porcelain | grep 'M Makefile.PL' && git add Makefile.PL || echo Makefile.PL up to date run = git status --porcelain | grep 'M README.pod' && git add README.pod || echo README.PL up to date run = git status --porcelain | grep 'M dist.ini' && git add dist.ini || echo dist.ini up to date run = git status --porcelain | grep 'M Makefile.PL' && git commit -m 'auto-committed by dist.ini' Makefile.PL || echo Makefile.PL up to date META.yml100644001750001750 136012652374305 14074 0ustar00kdkd000000000000Text-CSV-Encoded-0.25--- abstract: 'Encoding aware Text::CSV.' author: - 'Makamaka Hannyaharamitu, ' build_requires: perl: '5.008' configure_requires: ExtUtils::MakeMaker: '0' perl: '5.008' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.040, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Text-CSV-Encoded requires: IO::Handle: '0' Test::Harness: '0' Test::More: '0' Text::CSV: '1.31' perl: '5.008' resources: bugtracker: https://github.com/singingfish/Text-CSV-Encoded/issues homepage: https://github.com/singingfish/Text-CSV-Encoded repository: https://github.com/singingfish/Text-CSV-Encoded.git version: '0.25' MANIFEST100644001750001750 141012652374305 13750 0ustar00kdkd000000000000Text-CSV-Encoded-0.25# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.040. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README.pod dist.ini lib/Text/CSV/Encoded.pm lib/Text/CSV/Encoded/Coder/Base.pm lib/Text/CSV/Encoded/Coder/Encode.pm lib/Text/CSV/Encoded/Coder/EncodeGuess.pm sample/sjis.csv sample/utf8.csv t/00_pod.t t/01_use.t t/02_undef.t t/03_attr_err.t t/_setup.pm t/pp_01_base.t t/pp_02_code.t t/pp_03_file.t t/pp_04_uni_but_utf8.t t/pp_05_guess.t t/pp_06_coder_class.t t/pp_07_coder_check_value.t t/tests/01_base.t t/tests/02_code.t t/tests/03_file.t t/tests/04_uni_but_utf8.t t/tests/05_guess.t t/tests/06_coder_class.t t/tests/07_coder_check_value_euc-jp.t t/xs_01_base.t t/xs_02_code.t t/xs_03_file.t xt/author/pod-syntax.t xt/release/kwalitee.t META.json100644001750001750 264312652374305 14251 0ustar00kdkd000000000000Text-CSV-Encoded-0.25{ "abstract" : "Encoding aware Text::CSV.", "author" : [ "Makamaka Hannyaharamitu, " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.040, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Text-CSV-Encoded", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "perl" : "5.008" } }, "develop" : { "requires" : { "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "IO::Handle" : "0", "Test::Harness" : "0", "Test::More" : "0", "Text::CSV" : "1.31", "perl" : "5.008" } }, "test" : { "requires" : { "perl" : "5.008" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/singingfish/Text-CSV-Encoded/issues" }, "homepage" : "https://github.com/singingfish/Text-CSV-Encoded", "repository" : { "type" : "git", "url" : "https://github.com/singingfish/Text-CSV-Encoded.git", "web" : "https://github.com/singingfish/Text-CSV-Encoded" } }, "version" : "0.25" } t000755001750001750 012652374305 12726 5ustar00kdkd000000000000Text-CSV-Encoded-0.2500_pod.t100644001750001750 25212652374305 14313 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl use strict; $^W = 1; use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok (); 01_use.t100644001750001750 11612652374305 14325 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/tuse strict; use Test::More tests => 1; use_ok( 'Text::CSV::Encoded' ); README.pod100644001750001750 272112652374305 14266 0ustar00kdkd000000000000Text-CSV-Encoded-0.25=pod =head1 NAME Text::CSV::Encoded - Encoding aware Text::CSV. =head1 SYNOPSIS # Here in Perl 5.8 or later $csv = Text::CSV::Encoded->new ({ encoding_in => "iso-8859-1", # the encoding comes into Perl encoding_out => "cp1252", # the encoding comes out of Perl }); # parsing CSV is regarded as input $csv->parse( $line ); # $line is a iso-8859-1 encoded string @columns = $csv->fields(); # they are unicode data =head1 DESCRIPTION This module inherits L and is aware of input/output encodings. =head1 INSTALLATION This module sources are hosted on github https://github.com/singingfish/Text-CSV-Encoded and uses C to generate the distribution. It can be istalled: =over =item directly cpanm https://github.com/singingfish/Text-CSV-Encoded.git =item from CPAN cpan Text::CSV::Encoded cpanm https://github.com/singingfish/Text-CSV-Encoded =item maualy cloninig the repository: git clone https://github.com/singingfish/Text-CSV-Encoded.git cd https://github.com/singingfish/Text-CSV-Encoded perl Makefile.PL make make test make install =back =head1 REQUIREMENTS This distribution requires Perl v5.8.0. This distribution requires the following modules: =over 4 =item * L (version 1.41) =item * L (version 1.31) =back =head1 COPYRIGHT AND LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. _setup.pm100644001750001750 115512652374305 14725 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/tpackage _setup; use strict; sub tests { package main; plan tests => $_[1]; } BEGIN { package main; my $backend = $ARGV[0] || 0; local $ENV{PERL_TEXT_CSV} = $backend; require Text::CSV::Encoded; if ( $] < 5.008 ) { plan skip_all => "This test requires Perl version 5.8 or lator."; } elsif ( $backend and Text::CSV::Encoded->is_pp ) { plan skip_all => "Text::CSV_XS can't be loaded."; } elsif ( !$backend and Text::CSV::Encoded->is_xs ) { plan skip_all => "Text::CSV_PP can't be loaded."; } } 1; __END__ Makefile.PL100644001750001750 227412652374305 14602 0ustar00kdkd000000000000Text-CSV-Encoded-0.25# This Makefile.PL for Text-CSV-Encoded was generated by # Dist::Zilla::Plugin::MakeMaker::Awesome 0.35. # Don't edit it but the dist.ini and plugins used to construct it. use strict; use warnings; use 5.008; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Encoding aware Text::CSV.", "AUTHOR" => "Makamaka Hannyaharamitu, ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Text-CSV-Encoded", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.008", "NAME" => "Text::CSV::Encoded", "PREREQ_PM" => { "IO::Handle" => 0, "Test::Harness" => 0, "Test::More" => 0, "Text::CSV" => "1.31" }, "VERSION" => "0.25", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "IO::Handle" => 0, "Test::Harness" => 0, "Test::More" => 0, "Text::CSV" => "1.31" ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); 02_undef.t100644001750001750 72412652374305 14640 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t use strict; use Test::More; plan tests => 2; BEGIN { local $ENV{PERL_TEXT_CSV} = $ARGV[0] || 0; require Text::CSV::Encoded; } my $csv = Text::CSV::Encoded->new( { encoding_in => 'utf8', encoding_out => 'shiftjis' } ); $csv->blank_is_undef( 1 ); $csv->parse('abc,"",,"def"'); is_deeply( [ $csv->fields ], [ 'abc', '', undef, 'def' ] ); $csv->blank_is_undef( 0 ); $csv->parse('abc,"",,"def"'); is_deeply( [ $csv->fields ], [ 'abc', '', '', 'def' ] ); pp_02_code.t100644001750001750 23112652374305 15141 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl -w use strict; use Test::More; use lib qw(./t); use _setup; BEGIN { _setup->tests(16); } require './t/tests/02_code.t'; __END__ xs_01_base.t100644001750001750 26312652374305 15160 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl -w use strict; use Test::More; BEGIN { $ARGV[0] = 1; } use lib qw(./t); use _setup; BEGIN { _setup->tests(81); } require './t/tests/01_base.t'; __END__ pp_03_file.t100644001750001750 23212652374305 15150 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl -w use strict; use Test::More; use lib qw(./t); use _setup; BEGIN { _setup->tests(20); } require './t/tests/03_file.t'; __END__ xs_02_code.t100644001750001750 26212652374305 15160 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl -w use strict; use Test::More; BEGIN { $ARGV[0] = 1; } use lib qw(./t); use _setup; BEGIN { _setup->tests(16); } require './t/tests/02_code.t'; __END__ pp_01_base.t100644001750001750 23212652374305 15141 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl -w use strict; use Test::More; use lib qw(./t); use _setup; BEGIN { _setup->tests(81); } require './t/tests/01_base.t'; __END__ xs_03_file.t100644001750001750 26312652374305 15167 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl -w use strict; use Test::More; BEGIN { $ARGV[0] = 1; } use lib qw(./t); use _setup; BEGIN { _setup->tests(20); } require './t/tests/03_file.t'; __END__ 03_attr_err.t100644001750001750 42312652374305 15356 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/tuse strict; use Test::More; plan tests => 2; BEGIN { local $ENV{PERL_TEXT_CSV} = $ARGV[0] || 0; require Text::CSV::Encoded; } my $csv = Text::CSV::Encoded->new( { not_implemented_attr => 1 } ); ok( not $csv ); like( Text::CSV::Encoded->error_diag, qr/INI - / ); pp_05_guess.t100644001750001750 26412652374305 15366 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl -w use strict; use Test::More; #BEGIN { $ARGV[0] = 1; } use lib qw(./t); use _setup; BEGIN { _setup->tests(6); } require './t/tests/05_guess.t'; __END__ sample000755001750001750 012652374305 13744 5ustar00kdkd000000000000Text-CSV-Encoded-0.25sjis.csv100644001750001750 5712652374305 15533 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/sampleid,text 1,本日はいい天気 2,アイウエオ 3,テスト 4,★ utf8.csv100644001750001750 10712652374305 15465 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/sampleサソid,text 1,譛ャ譌・縺ッ縺縺螟ゥ豌 2,スアスイスウスエスオ 3,繝繧ケ繝 4,笘 tests000755001750001750 012652374305 14070 5ustar00kdkd000000000000Text-CSV-Encoded-0.25/t02_code.t100644001750001750 270512652374305 15634 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t/tests use strict; use utf8; my $csv = Text::CSV::Encoded->new(); my @tests = ( # encoding CSV Perl Str Re-CSV [ [ unicode => undef ] => "テシ", "テシ", "テシ" ], [ [ latin1 => undef ] => "\xfc", "\xfc", "\xfc" ], [ [ latin1 => 'latin1' ] => "\xfc", "\xfc", "\xfc" ], [ [ utf8 => undef ] => "\xc3\xbc", "\xc3\xbc", qq|"\xc3\xbc"| ], [ [ unicode => 'utf8' ] => "\xc3\xbc", "テシ", "\xc3\xbc" ], [ [ unicode => undef ] => '縺,縺', '縺,縺', '"縺","縺"' ], [ [ unicode => 'utf8' ] => "\xE3\x81\x82,\xE3\x81\x84", '縺,縺', qq|"\xE3\x81\x82","\xE3\x81\x84"| ], [ [ unicode => 'shiftjis' ] => "\x82\xA0,\x82\xA2", '縺,縺', qq|"\x82\xA0","\x82\xA2"| ], ); for my $t ( @tests ) { my ( $name, $code ) = @{ $t->[0] }; $name .= " (<=$code)" if $code; my $columns = $code ? $csv->decode( $code, $t->[1] ) : $csv->decode( $t->[1] ); is( join( ',', @$columns ), $t->[2], $name . ' decode' ); my $string = $code ? $csv->encode( $code, $columns ) : $csv->encode( $columns ); is( $string, $t->[3], $name . ' encode' ); } 1; 03_file.t100644001750001750 445512652374305 15646 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t/testsuse Encode; use utf8; my $csv = Text::CSV::Encoded->new({ encoding_in => 'utf8', encoding_out => 'shiftjis', }); my $file = sprintf('sample/test_%s.csv' , $csv->backend =~ /PP/ ? 'pp' : 'xs' ); open (my $fh, "sample/utf8.csv") or die $!; open (my $fh2, ">$file") or die $!; # # column_names & getline_hr # $csv->column_names( $csv->getline($fh) ); while( my $hr = $csv->getline_hr( $fh ) ) { $csv->print( $fh2, [ $hr->{text} ] ); $fh2->print("\n"); } close($fh); close($fh2); my $checker = Text::CSV->new({ binary => 1}); open ($fh, $file) or die $!; open ($fh2, "sample/sjis.csv") or die $!; <$fh2>; $csv->encoding_in( 'shiftjis' ); while( 1 ) { my $row = $csv->getline( $fh ); $csv->eof and last; is( Encode::encode( 'shiftjis', $row->[0] ), $checker->getline( $fh2 )->[1] ); } close($fh); close($fh2); # convert directly # shiftjis open ($fh, $file) or die $!; open ($fh2, "sample/sjis.csv") or die $!; <$fh2>; $csv->encoding_in( 'shiftjis' ); $csv->encoding( 'shiftjis' ); while( 1 ) { my $row = $csv->getline( $fh ); $csv->eof and last; is( $row->[0], $checker->getline( $fh2 )->[1] ); } close($fh); close($fh2); # utf8 open ($fh, $file) or die $!; open ($fh2, "sample/utf8.csv") or die $!; <$fh2>; $csv->encoding_in( 'shiftjis' ); $csv->encoding( 'utf8' ); while( 1 ) { my $row = $csv->getline( $fh ); $csv->eof and last; my $string = $checker->getline( $fh2 )->[1]; $string = encode_utf8( $string ) if ( $csv->automatic_UTF8 ); is( $row->[0], $string ); } close($fh); close($fh2); # unicode open ($fh, $file) or die $!; open ($fh2, "sample/utf8.csv") or die $!; <$fh2>; $csv->encoding_in( 'shiftjis' ); $csv->encoding( undef ); while( 1 ) { my $row = $csv->getline( $fh ); $csv->eof and last; my $data = $checker->getline( $fh2 )->[1]; is( $row->[0], utf8::is_utf8 ($data) ? $data : Encode::decode_utf8( $data ) ); } close($fh); close($fh2); # # bind_columns # my ( $id, $text ); $csv->bind_columns( \$id, \$text ); $csv->encoding_in( 'utf8' ); $csv->encoding( 'shiftjis' ); open ($fh, $file) or die $!; open ($fh2, "sample/utf8.csv") or die $!; <$fh2>; while( my $col = $csv->getline( $fh2 ) ) { is( $text, $checker->getline( $fh )->[0] ); } close($fh); close($fh2); unlink( $file ) or warn $!; 1; 01_base.t100644001750001750 232012652374305 15624 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t/tests#!/usr/bin/perl -w use strict; use utf8; use Encode qw(encode decode); #Test::More::diag ( "This backend is ", Text::CSV::Encoded->backend ); my $csv = Text::CSV::Encoded->new({}); for my $enc_in ( undef, qw(latin1 utf8) ) { for my $enc_out ( undef, qw(latin1 utf8) ) { $csv->encoding_in ( $enc_in ); $csv->encoding_out( $enc_out ); ok( $csv->parse( $enc_in ? encode( $enc_in, "テシ" ) : "テシ" ) ); is( ($csv->fields)[0], "テシ" ); # always Unicode ok( $csv->combine( $csv->fields ) ); is( $csv->string, $enc_out ? encode( $enc_out, "テシ" ) : "テシ" ); } } for my $enc_in ( undef, qw(shiftjis utf8) ) { for my $enc_out ( undef, qw(shiftjis utf8) ) { $csv->encoding_in ( $enc_in ); $csv->encoding_out( $enc_out ); my $subject = $enc_in ? $enc_in : 'Unicode'; $subject .= " => "; $subject .= $enc_out ? $enc_out : 'Unicode'; ok(1, $subject); ok( $csv->parse( $enc_in ? encode( $enc_in, "縺" ) : "縺" ) ); is( ($csv->fields)[0], '縺' ); # always Unicode ok( $csv->combine( $csv->fields ) ); is( $csv->string, $enc_out ? encode( $enc_out, '"縺"' ) : '"縺"' ); } } 1; 05_guess.t100644001750001750 151112652374305 16045 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t/tests use strict; use utf8; use Text::CSV::Encoded coder_class => 'Text::CSV::Encoded::Coder::EncodeGuess'; my $csv = Text::CSV::Encoded->new; $csv->encoding( ['shiftjis', 'euc-jp'] ); # guessing euc-jp or shiftjis? $csv->encoding_out('shiftjis'); my @fields = ( Encode::encode('euc-jp', '縺薙l縺ッEUC-JP'), Encode::encode('shiftjis', '縺薙l縺ッShift_JIS') ); ok( $csv->combine( @fields ) ); is( $csv->string, Encode::encode( 'shiftjis', '"縺薙l縺ッEUC-JP","縺薙l縺ッShift_JIS"' ) ); $csv->encoding_to_parse( ['shiftjis', 'euc-jp'] ); # guessing euc-jp or shiftjis? $csv->encoding( undef ); ok( $csv->parse( Encode::encode('euc-jp', '縺薙l縺ッEUC-JP') ) ); is( join('', $csv->fields), '縺薙l縺ッEUC-JP' ); ok( $csv->parse( Encode::encode('shiftjis', '縺薙l縺ッShift_JIS') ) ); is( join('', $csv->fields), '縺薙l縺ッShift_JIS' ); 1; pp_06_coder_class.t100644001750001750 62312652374305 16521 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t#!/usr/bin/perl -w use strict; use Test::More tests => 2; use Text::CSV::Encoded; my $csv = Text::CSV::Encoded->new( ); is( $csv->coder_class, $] >= 5.008 ? 'Text::CSV::Encoded::Coder::Encode' : 'Text::CSV::Encoded::Coder::Base' ); $csv = Text::CSV::Encoded->new( { coder_class => 'Text::CSV::Encoded::Coder::Base' } ); is( $csv->coder_class, 'Text::CSV::Encoded::Coder::Base' ); __END__ release000755001750001750 012652374305 14536 5ustar00kdkd000000000000Text-CSV-Encoded-0.25/xtkwalitee.t100644001750001750 46312652374305 16653 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/xt/release#!perl # This test is generated by Dist::Zilla::Plugin::Test::Kwalitee::Extra use strict; use warnings; use Test::More; # needed to provide plan. eval { require Test::Kwalitee::Extra }; plan skip_all => "Test::Kwalitee::Extra required for testing kwalitee: $@" if $@; eval "use Test::Kwalitee::Extra"; pp_04_uni_but_utf8.t100644001750001750 20412652374305 16644 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t use strict; use Test::More; use lib qw(./t); use _setup; BEGIN { _setup->tests(2); } require './t/tests/04_uni_but_utf8.t'; author000755001750001750 012652374305 14420 5ustar00kdkd000000000000Text-CSV-Encoded-0.25/xtpod-syntax.t100644001750001750 25212652374305 17032 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); CSV000755001750001750 012652374305 14610 5ustar00kdkd000000000000Text-CSV-Encoded-0.25/lib/TextEncoded.pm100644001750001750 4566412652374305 16706 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/lib/Text/CSVpackage Text::CSV::Encoded; $Text::CSV::Encoded::VERSION = '0.25'; use strict; use warnings; use Carp (); # VERSION BEGIN { require Text::CSV; if ( Text::CSV->VERSION < 1.06 ) { Carp::croak "Base class Text::CSV version is less than 1.06."; } my $backend = Text::CSV->backend; my $version = Text::CSV->backend->VERSION; if ( ( $backend =~ /XS/ and $version >= 0.99 ) or ( $backend =~ /PP/ and $version >= 1.30 ) ) { eval q/ sub automatic_UTF8 { 1; } /; # parse/getline return strings (UNICODE) } else { eval q/ sub automatic_UTF8 { 0; } /; } } use base qw( Text::CSV ); my $DefaultCoderClass = $] >= 5.008 ? 'Text::CSV::Encoded::Coder::Encode' : 'Text::CSV::Encoded::Coder::Base'; my @Attrs; BEGIN { @Attrs = qw( encoding encoding_in encoding_out encoding_io_in encoding_io_out encoding_to_parse encoding_to_combine ); } sub import { my ( $class, %args ) = @_; return unless %args; if ( exists $args{ coder_class } ) { $DefaultCoderClass = $args{ coder_class }; } } sub new { my $class = shift; my $opt = shift || {}; my %opt; $opt->{binary} = 1; for my $attr ( @Attrs, 'encoding', 'coder_class' ) { $opt{ $attr } = delete $opt->{ $attr } if ( exists $opt->{ $attr } ); } my $self = $class->SUPER::new( $opt ) || return; if ( my $coder_class = ( $opt{coder_class} || $DefaultCoderClass ) ) { $self->coder_class( $coder_class ); } else { Carp::croak "Coder class is not specified."; } for my $attr ( @Attrs, 'encoding' ) { $self->$attr( $opt{ $attr } ) if ( exists $opt{ $attr } ); } $self; } # # Methods # sub combine { my $self = shift; my @fields = @_; $self->coder->decode_fields_ref( $self->encoding, \@fields ) if ( $self->encoding ); unless ( $self->encoding_out ) { return $self->SUPER::combine( @fields ); } my $ret = $self->encode( $self->encoding_out, \@fields ); $self->{_STRING} = \$ret if ( $ret ); return $self->{_STATUS}; } sub parse { my $self = shift; my $ret; if ( $self->encoding_in ) { $ret = $self->decode( $self->encoding_in, $_[0] ); } else { $ret = [ $self->fields ] if $self->SUPER::parse( @_ ); } if ( $ret ) { $self->coder->encode_fields_ref( $self->encoding, $ret ) if ( $self->encoding ); $self->{_FIELDS} = $ret; } return $self->{_STATUS}; } # # IO style # sub print { # to CSV my ( $self, $io, $cols ) = @_; $self->coder->decode_fields_ref( $self->encoding, $cols ) if ( $self->encoding ); $self->coder->encode_fields_ref( $self->encoding_out, $cols ); $self->SUPER::print( $io, $cols ); } sub getline { # from CSV my ( $self, $io ) = @_; my $cols = $self->SUPER::getline( $io ); if ( my $binds = $self->{_BOUND_COLUMNS} ) { for my $val ( @$binds ) { $$val = $self->coder->decode( $self->encoding_in, $$val ); $$val = $self->coder->encode( $self->encoding, $$val ) if ( $self->encoding ); } return $cols; } return unless $cols; $self->coder->decode_fields_ref( $self->encoding_in, $cols ); $self->coder->encode_fields_ref( $self->encoding, $cols ) if ( $self->encoding ); $cols; } # # decode/encode style # sub decode { my ( $self, $enc, $text ) = @_; if ( @_ == 2 ) { $text = $enc, $enc = ''; } $self->coder->upgrade( $text ) unless ( $enc ); # as unicode return unless ( defined $text ); return unless ( $self->SUPER::parse( $text ) ); return $enc ? [ map { $self->coder->decode( $enc, $_ ) } $self->fields() ] : [ $self->fields() ]; } sub encode { my ( $self, $enc, $array ) = @_; if ( @_ == 2 ) { $array = $enc, $enc = ''; } return unless ( defined $array and ref $array eq 'ARRAY' ); return unless ( $self->SUPER::combine ( @$array ) ); return $enc ? $self->coder->encode( $enc, $self->string() ) : $self->string(); } # Internal sub _load_coder_class { my ( $class, $coder_class ) = @_; (my $file = "$coder_class.pm") =~ s{::}{/}g; eval { require $file }; if ( $@ ) { Carp::croak $@; } $coder_class; } # Accessors BEGIN { for my $method ( qw( encoding encoding_in encoding_out ) ) { eval qq| sub $method { my ( \$self, \$encoding ) = \@_; if ( \@_ > 1 ) { \$self->{ $method } = \$encoding; return \$self; } else { \$self->{ $method }; } } |; } } *encoding_io_in = *encoding_to_parse = *encoding_in; *encoding_io_out = *encoding_to_combine = *encoding_out; sub coder { my $self = shift; $self->{coder} ||= $self->coder_class->new( automatic_UTF8 => $self->automatic_UTF8, @_ ); } sub coder_class { my ( $self, $coder_class ) = @_; return $self->{coder_class} if ( @_ == 1 ); $self->_load_coder_class( $coder_class ); $self->{coder_class} = $coder_class; $self; } 1; __END__ =pod =head1 NAME Text::CSV::Encoded - Encoding aware Text::CSV. =head1 VERSION version 0.25 =head1 SYNOPSIS # Here in Perl 5.8 or later $csv = Text::CSV::Encoded->new ({ encoding_in => "iso-8859-1", # the encoding comes into Perl encoding_out => "cp1252", # the encoding comes out of Perl }); # parsing CSV is regarded as input $csv->parse( $line ); # $line is a iso-8859-1 encoded string @columns = $csv->fields(); # they are unicode data =for readme stop # combining list is regarded as output $csv->combine(@columns); # they are unicode data $line = $csv->string(); # $line is a cp1252 encoded string # if you want for returned @columns to be encoded in $encoding # or want for combining @columns to be assumed in $encoding $csv->encoding( $encoding ); # change input/output encodings $csv->encoding_in('shiftjis')->encoding_out('utf8'); $csv->eol("\n"); open (my $in, "sjis.csv"); open (my $out, "output.csv"); # change an encoding from shiftjis to utf8 while( my $columns = $csv->getline( $in ) ) { $csv->print( $out, $columns ); } close($in); close($out); # simple shortcuts # (regardless of encoding_in/out and encoding) $uni_columns = $csv->decode( 'euc-jp', $line ); # euc-jp => unicode $line = $csv->encode( 'euc-jp', $uni_columns ); # unicode => euc-jp # pass check value to coder class $csv->coder->encode_check_value( Encode::FB_PERLQQ ); =for readme start =head1 DESCRIPTION This module inherits L and is aware of input/output encodings. =begin :readme =head1 INSTALLATION This module sources are hosted on github https://github.com/singingfish/Text-CSV-Encoded and uses C to generate the distribution. It can be istalled: =over =item directly cpanm https://github.com/singingfish/Text-CSV-Encoded.git =item from CPAN cpan Text::CSV::Encoded cpanm https://github.com/singingfish/Text-CSV-Encoded =item maualy cloninig the repository: git clone https://github.com/singingfish/Text-CSV-Encoded.git cd https://github.com/singingfish/Text-CSV-Encoded perl Makefile.PL make make test make install =back =for readme plugin requires =head1 COPYRIGHT AND LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =end :readme =for readme stop =head1 ENCODINGS Acceptable names of encodings (C, C and C) are depend upon its coder class (see to L). But these names should be based on L supported names. See to L and L. =head1 METHODS =head2 new $csv = Text::CSV::Encoded->new(); Text::CSV::Encoded->error_diag unless $csv; # report error message Creates a new Text::CSV::Encoded object. It can take all options of L. Of course, C option is always on. If Text::CSV::Encoded fails in constructing, you can get an error message using C. See to L. The following options are supported by this method: =over =item encoding The encoding of list data in below cases. * list data returned by fields() after successful parse(). * list data consumed by combine(). * list reference returned by getline(). * list reference taken by print(). See to L. =item encoding_in =item encoding_io_in =item encoding_to_parse The encoding for pre-parsing CSV strings. See to L. C is an alias to C. If both C and C are set at the same time, the C takes precedence. C is an alias to C. If both C and C are set at the same time, the C takes precedence. =item encoding_out =item encoding_io_out =item encoding_to_combine The encoding for combined CSV strings. See to L. C is an alias to C. If both C and C are set at the same time, the C takes precedence. C is an alias to C. If both C and C are set at the same time, the C takes precedence. =item coder_class A name of coder class that really decodes and encodes data. =back =head2 encoding_in $csv = $csv->encoding_in( $encoding ); The accessor to an encoding for pre-parsing CSV strings. If no encoding is given, returns current C<$encoding>, otherwise the object itself. $encoding = $csv->encoding_in() In C or C, the C<$csv> will assume CSV data as the given encoding. If C is not specified or is set with false value (L), it will assume input CSV strings as Unicode (not UTF-8) when L is used. $csv->encoding_in( undef ); # assume as Unicode when Text::CSV::Encoded::Coder::Encode is used. If you pass a list reference that contains multiple encodings to the method, the working are depend upon the coder class. For example, if you use the coder class with L, it might guess the encoding from the given list. $csv->coder_class( 'Text::CSV::Encoded::Coder::EncodeGuess' ); $csv->encoding_in( ['shiftjis', 'euc-jp', 'iso-20022-jp'] ); See to L and L. =head2 encoding_out $csv = $csv->encoding_out( $encoding ); The accessor to an encoding for converting combined CSV strings. If no encoding is given, returns current C<$encoding>, otherwise the object itself. $encoding = $csv->encoding_out(); In C or C, the C<$csv> will return a result string encoded in the given encoding. If C is not specified or is set with false value, it will return a result string as Unicode (not UTF-8). $csv->encoding_out( undef ); # return as Unicode when Text::CSV::Encoded::Coder::Encode is used. You must not pass a list reference to C, unlike C or C. =head2 encoding $csv = $csv->encoding( $encoding ); $encoding = $csv->encoding(); The accessor to an encoding for list data in the below cases. * list data returned by fields() after successful parse(). * list data consumed by combine(). * list reference returned by getline(). * list reference taken by print(). In other word, in C and C, C is an encoding of the returned list. And in C and C, it is assumed as an encoding for the passing list data. If C is not specified or is set with false value (C), the field data will be regarded as Unicode (when L is used). # ex.) a souce code is encoded in euc-jp, and print to stdout in shiftjis. @fields = ( .... ); $csv->encoding('euc-jp') ->encoding_to_combine('shiftjis') # same as encoding_out ->combine( @fields ); # from euc-jp to shift_jis print $csv->string; $csv->encoding('shiftjis') ->encoding_to_parse('shiftjis') # same as encoding_in ->parse( $csv->string ); # from shift_jis to shift_jis print join(", ", $csv->fields ); If you pass a list reference contains multiple encodings to the method, The working are depend upon the coder class. For example, L might guess the encoding from the given list. $csv->coder_class( 'Text::CSV::Encoded::Coder::EncodeGuess' ); $csv->encoding( ['ascii', 'ucs2'] )->combine( @cols ); See to L and L. =head2 parse/combine/getline/print $csv->parse( $encoded_string ); @unicode_array = $csv->fields(); $csv->combine( @unicode_array ); $encoded_string = $csv->string; $unicode_arrayref = $csv->getline( $io ); # get arrayref contains unicode strings $csv->print( $io, $unicode_arrayref ); # print $io with string encoded in $csv->encoded_in. $encoded_arrayref = $csv->getline( $io => $encoding ) # directly encoded in $encoding. Here is the relation of C, C and C. # CSV string => (getline/parsed) => Perl array # assumed as encoded in # encoding_in encoding # Perl array => (print/combined) => CSV string # assumed as encoded in # encoding encoding_out If you want to treat Perl array data as Unicode in Perl5.8 and later, don't specify C (or set C into C). =head2 decode $arrayref = $csv->decode( $encoding, $encoded_string ); $arrayref = $csv->decode( $string ); A short cut method to convert CSV to Perl. Without C<$encoding>, C<$string> is assumed as a Unicode. The returned value status is depend upon its coder class. With L, C<$arrayref> contains Unicode strings. =head2 encode $encoded_string = $csv->encode( $encoding, $arrayref ); $string = $csv->encode( $arrayref ); A short cut method to convert Perl to CSV. With L, C<$arrayref> is assumed to contain Unicode strings. Without C<$encoding>, return as is. =head2 coder_class $csv = $csv->coder_class( $classname ); $classname = $csv->coder_class(); Returns the coder class name. See to L. =head2 coder $coder = $csv->coder(); Returns a coder object. =head2 automtic_UTF8 In L version 0.99 and L version 1.30 or later, They return UNICODE stinrgs in case of parsing utf8 encoded text. Backend module has that feature, automatic_UTF8 returns true. (This method is for internal code.) =head1 CODER CLASS Text::CSV::Encoded delegates the encoding converting process to another module. Since version 5.8, Perl standardly has L module. So the default coder module L also uses it. In this case, you don't have to take care of it. In older Perl, the default is L. It does nothing. So you have to make a coder module using your favorite converting module, for example, L or L and so on. Please check L and L to make such a module. In calling L, you can set another coder module with C; use Text::CSV::Encoded coder_class => 'YourCoder'; This will call C module in runtime. =head2 Use Encode module Perl 5.8 or later, L use L as its backend engine. You can set C, C and C with L supported encodings. See to L and L. Without C (or set C), C/C/C return list data whose entries are C strings. On the contrary, C/C take data as C string list. About the extra methods C and C. C returns C string list and C takes C string list. But If no C<$encoding> is passed to C, it returns a non-Unicode CSV string for non-Unicode list data. =head2 Use Encode::Guess module If you don't know definitely input CSV data encoding (for parse/getline), L may be useful to you. It inherits from L, so you can treate methods and attributes as same as L. And it provides a guessing fucntion with L. When it is backend coder class, C and C can take a encoding list reference, and then it might guess the encoding from the given list. $csv->encoding_in( ['shiftjis', 'euc-jp'] )->parse( $sjis_or_eucjp_encoded_csv_string ); It is important to remember the guessing feature is not always successful. Or, the method can be applied to C. For exmaple, you want to convert data from Microsoft Excel to CSV. use Text::CSV::Encoded coder_class => 'Text::CSV::Encoded::Coder::EncodeGuess'; use Spreadsheet::ParseExcel; my $csv = Text::CSV::Encoded->new( eol => "\n" ); $csv->encoding( ['ucs2', 'ascii'] ); # guessing ucs2 or ascii? $csv->encoding_out('shiftjis'); # print in shift_jis my $excel = Spreadsheet::ParseExcel::Workbook->Parse( $file ); my $sheet = $excel->{Worksheet}->[0]; for my $row ( $sheet->{MinRow} .. $sheet->{MaxRow} ) { my @fields; for my $col ( $sheet->{MinCol} .. $sheet->{MaxCol} ) { my $cell = $sheet->{Cells}[$row][$col]; push @fields, $cell->{Val}; } $csv->print( \@fields ); } In this case, guessing for list data. After combining, you may have a need to clear C. Again remember that the feature is not always successful. In addtion, Microsoft Excel data converting is a carefult thing. See to L. =head2 Use XXX module Someone might make a new coder module in older version Perl... There is an example with L in L document. =head1 TODO =over =item More sophisticated tests - Welcome! =item Speed =back =head1 SEE ALSO L, L, L, L, L, L, L, L =head1 AUTHOR Makamaka Hannyaharamitu, Emakamaka[at]cpan.orgE The basic idea for this module and suggestions were given by H.Merijn Brand. He and Juerd advised me many points about documents and sources. =head1 COPYRIGHT AND LICENSE Copyright 2008-2013 by Makamaka Hannyaharamitu This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 06_coder_class.t100644001750001750 46112652374305 17164 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t/tests use strict; use Text::CSV::Encoded; my $csv = Text::CSV::Encoded->new( ); is( $csv->coder_class, 'Text::CSV::Encoded::Coder::Encode' ); $csv = Text::CSV::Encoded->new( { coder_class => 'Text::CSV::Encoded::Coder::Base' } ); is( $csv->coder_class, 'Text::CSV::Encoded::Coder::Base' ); 1; __END__ 04_uni_but_utf8.t100644001750001750 35512652374305 17316 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t/tests use strict; use utf8; use Text::CSV::Encoded; my $csv = Text::CSV::Encoded->new; eval q| $csv->decode( "縺ゅ>縺縺医♀" ) |; ok( !$@ ); eval q| $csv->decode('utf8', "縺ゅ>縺縺医♀") |; ok( $csv->automatic_UTF8 ? 1 : $@ ); 1; pp_07_coder_check_value.t100644001750001750 23212652374305 17662 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t use strict; use Test::More; use lib qw(./t); use _setup; BEGIN { _setup->tests(2); } require './t/tests/07_coder_check_value_euc-jp.t'; __END__ Coder000755001750001750 012652374305 17205 5ustar00kdkd000000000000Text-CSV-Encoded-0.25/lib/Text/CSV/EncodedBase.pm100644001750001750 767712652374305 20576 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/lib/Text/CSV/Encoded/Coderpackage Text::CSV::Encoded::Coder::Base; $Text::CSV::Encoded::Coder::Base::VERSION = '0.25'; # VERSION use strict; use warnings; sub new { my $class = shift; my %opt = @_; bless { %opt }, $class; } sub upgrade { 0; } sub encode { my ( $self, $encoding, $str ) = @_; $str; } sub decode { my ( $self, $encoding, $str ) = @_; $str; } sub decode_fields_ref { my ( $self, $encoding, $arrayref ) = @_; } sub encode_fields_ref { my ( $self, $encoding, $arrayref ) = @_; } sub encode_check_value { $_[0]->{ encode_check_value } = $_[1] if @_ > 1; $_[0]->{ encode_check_value } || 0; } sub decode_check_value { $_[0]->{ decode_check_value } = $_[1] if @_ > 1; $_[0]->{ decode_check_value } || 0; } 1; __END__ =pod =head1 NAME Text::CSV::Encoded::Coder::Base - Interface for Text::CSV::Encoded coder base class =head1 VERSION version 0.25 =head1 SYNOPSIS package Text::CSV::Encoded::Coder::YourCoder; use base qw( Text::CSV::Encoded::Coder::Base ); sub decode { ... } sub encode { ... } sub upgrade { ... } sub decode_fields_ref { ... } sub encode_fields_ref { ... } =head1 DESCRIPTION This module is used by L internally. =head1 INTERFACS =head2 decode ( $self, $encoding, $str ) = @_; .... return $decoded_str; Takes an encoding and a CSV string. It must return a Perl string decoded in C<$encoding>. In Perl 5.8 or later, if $enc is C or false, the encoding should be utf8. =head2 encode ( $self, $encoding, $str ) = @_; .... return $encoded_str; Takes an encoding and a Perl string. It must return a CSV string encoded in C<$encoding>. In Perl 5.8 or later, if $enc is C or false, the encoding should be utf8. =head2 decode_fields_ref ( $self, $encoding, $arrayref ) = @_; Takes an encoding and an array reference. It must decoded each array entries in $encoding. =head2 encode_fields_ref ( $self, $encoding, $arrayref ) = @_; Takes an encoding and an array reference. It must encoded each array entries in $encoding. =head2 upgrade ( $self, $str ) = @_; In Perl 5.8 or later, it is expected to do C against $str. In older versions, this method may be meaningless and there is no need to implement. See to L. =head2 encode_check_value Setter/Getter for an argument passing to encode. $coder->encode_check_value( Encode::FB_PERLQQ ); =head2 decode_check_value Setter/Getter for an argument passing to decode. $coder->encode_check_value( Encode::FB_PERLQQ ); =head1 EXAMPLE Use with L. package Text::CSV::Encoded::Coder::Jcode; use strict; use base qw( Text::CSV::Encoded::Coder::Base ); use Jcode (); my $Jcode = Jcode->new; my %alias = ( 'shiftjis' => 'sjis', 'euc-jp' => 'euc', 'sjis' => 'sjis', 'euc' => 'euc', ); sub decode { my ( $self, $encoding, $str ) = @_; my $enc = $alias{ $encoding }; $Jcode->set( $str, $enc )->euc; } sub encode { my ( $self, $encoding, $str ) = @_; my $enc = $alias{ $encoding }; $Jcode->set( $str, 'euc' )->$enc(); } sub decode_fields_ref { my ( $self, $encoding, $arrayref ) = @_; my $enc = $alias{ $encoding }; for ( @$arrayref ) { $_ = $Jcode->set( $_, $enc )->euc; } } sub encode_fields_ref { my ( $self, $encoding, $arrayref ) = @_; my $enc = $alias{ $encoding }; for ( @$arrayref ) { $_ = $Jcode->set( $_, 'euc' )->$enc(); } } =head1 AUTHOR Makamaka Hannyaharamitu, Emakamaka[at]cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2013 by Makamaka Hannyaharamitu This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode.pm100644001750001750 424212652374305 21102 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/lib/Text/CSV/Encoded/Coderpackage Text::CSV::Encoded::Coder::Encode; $Text::CSV::Encoded::Coder::Encode::VERSION = '0.25'; use 5.008; use strict; use warnings; # VERSION use base qw( Text::CSV::Encoded::Coder::Base ); use Carp (); use Encode (); my %EncoderCache; sub upgrade { utf8::upgrade( $_[1] ) if ( $_[1] ); } sub encode { my ( $self, $encoding, $str ) = @_; return undef unless defined $str; $self->find_encoding( $encoding )->encode( $str, $self->encode_check_value ); } sub decode { my ( $self, $encoding, $str ) = @_; return undef unless defined $str; if ( $self->{automatic_UTF8} and $encoding =~ /utf-?8/i ) { return $str; } $self->find_encoding( $encoding )->decode( $str, $self->decode_check_value ); } sub decode_fields_ref { my ( $self, $encoding, $arrayref ) = @_; if ( $self->{automatic_UTF8} and $encoding =~ /utf-?8/i ) { return; } my $enc = $self->find_encoding( $encoding ) || return; for ( @$arrayref ) { $_ = $enc->decode( $_, $self->decode_check_value ) if defined $_; } } sub encode_fields_ref { my ( $self, $encoding, $arrayref ) = @_; my $enc = $self->find_encoding( $encoding ) || return; for ( @$arrayref ) { $_ = $enc->encode( $_, $self->encode_check_value ) if defined $_; } } sub find_encoding { shift; $EncoderCache { ($_[0] || 'utf8') } ||= Encode::find_encoding( $_[0] || 'utf8' ) || Carp::croak ( "Not found such an encoding name '$_[0]'" ); } 1; __END__ =pod =head1 NAME Text::CSV::Encoded::Coder::Encode - Text::CSV::Encoded coder class using Encode =head1 VERSION version 0.25 =head1 SYNOPSIS use Text::CSV::Encoded coder_class => 'Text::CSV::Encoded::Coder::Encode'; # In Perl 5.8 or later, it is a default module. =head1 DESCRIPTION This module is used by L internally. =head1 SEE ALSO L, L, L, L =head1 AUTHOR Makamaka Hannyaharamitu, Emakamaka[at]cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2013 by Makamaka Hannyaharamitu This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 07_coder_check_value_euc-jp.t100644001750001750 136512652374305 21620 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/t/tests#!/usr/bin/perl -w # This file is encoded in EUC-JP, and output is Shift_JIS. # 、ウ、ホ・ユ・。・、・、ホ・ィ・・ウ。シ・ヌ・」・・ー、マEUC-JP。「スミホマ、マShift_JIS。」 use strict; BEGIN { local $ENV{PERL_TEXT_CSV} = $ARGV[0] || 0; require Text::CSV::Encoded; } use Encode; my $str = '、「,、、,。チ,ュ。'; my $check = encode( 'shiftjis', decode( 'euc-jp', '"、「","、、","。チ",' ) ); my @cols; my $csv = Text::CSV::Encoded->new( { encoding_in => 'euc-jp', encoding_out => 'shiftjis' } ); $csv->parse( $str ); @cols = $csv->fields; $csv->combine( @cols ); is( $csv->string, $check . '"?"' ); # change check value $csv->coder->encode_check_value( Encode::FB_PERLQQ ); $csv->parse( $str ); @cols = $csv->fields; $csv->combine( @cols ); is( $csv->string, $check . '"\x{2460}"' ); 1; EncodeGuess.pm100644001750001750 667712652374305 22127 0ustar00kdkd000000000000Text-CSV-Encoded-0.25/lib/Text/CSV/Encoded/Coderpackage Text::CSV::Encoded::Coder::EncodeGuess; $Text::CSV::Encoded::Coder::EncodeGuess::VERSION = '0.25'; use 5.008; use strict; use warnings; # VERSION use base qw( Text::CSV::Encoded::Coder::Encode ); use Carp (); use Encode (); use Encode::Guess; sub decode { my ( $self, $encoding, $str ) = @_; return undef unless defined $str; if ( ref $encoding ) { my $enc = Encode::Guess::guess_encoding( $str, @$encoding ); $enc = $self->find_encoding( $encoding->[0] ) unless ref $enc; return $enc->decode( $str, $self->decode_check_value ); } $self->find_encoding( $encoding )->decode( $str, $self->decode_check_value ); } sub decode_fields_ref { my ( $self, $encoding, $arrayref ) = @_; if ( ref $encoding ) { for ( @$arrayref ) { my $enc = Encode::Guess::guess_encoding( $_, @$encoding ); $enc = $self->find_encoding( $encoding->[0] ) unless ref $enc; $_ = $enc->decode( $_, $self->decode_check_value ); } } else { my $enc = $self->find_encoding( $encoding ) || return; for ( @$arrayref ) { $_ = $enc->decode( $_, $self->decode_check_value ); } } } 1; __END__ =pod =head1 NAME Text::CSV::Encoded::Coder::EncodeGuess - Text::CSV::Encoded coder class using Encode::Guess =head1 VERSION version 0.25 =head1 SYNOPSIS use Text::CSV::Encoded coder_class => 'Text::CSV::Encoded::Coder::EncodeGuess'; use Spreadsheet::ParseExcel; my $csv = Text::CSV::Encoded->new(); $csv->encoding( ['ucs2', 'ascii'] ); # guessing ucs2 or ascii? $csv->encoding_to_combine('shiftjis'); my $excel = Spreadsheet::ParseExcel::Workbook->Parse( $file ); my $sheet = $excel->{Worksheet}->[0]; for my $row ( $sheet->{MinRow} .. $sheet->{MaxRow} ) { my @fields; for my $col ( $sheet->{MinCol} .. $sheet->{MaxCol} ) { my $cell = $sheet->{Cells}[$row][$col]; push @fields, $cell->{Val}; } $csv->combine( @fields ) or die; print $csv->string, "\n"; } =head1 DESCRIPTION This module is inherited from L. =head1 USE Except for 2 attributes, same as L. =head2 encoding_in $csv = $csv->encoding_in( $encoding_list_ref ); The accessor to an encoding for pre-parsing CSV strings. If no encoding is given, returns current C<$encoding>, otherwise the object itself. $encoding_list_ref = $csv->encoding_in() When you pass a list reference, it might guess the encoding from the given list. $csv->encoding_in( ['shiftjis', 'euc-jp', 'iso-20022-jp'] ); If it cannot guess the encoding, the first encoding of the list is used. =head2 encoding $csv = $csv->encoding( $encoding_list_ref ); $encoding_list_ref = $csv->encoding(); You can pass a list reference to this attribute only: * For list data consumed by combine(). * For list reference returned by getline(). In other word, in C and C, it might guess an encoding for the passing list data. If it cannot guess the encoding, the first encoding of the list is used. =head1 SEE ALSO L, L =head1 AUTHOR Makamaka Hannyaharamitu, Emakamaka[at]cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2013 by Makamaka Hannyaharamitu This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut