utf8-all-0.017/0000775000175000017500000000000012621557530011621 5ustar mikemikeutf8-all-0.017/LICENSE0000644000175000017500000004376212621557530012640 0ustar mikemikeThis software is copyright (c) 2009 by Michael Schwern . 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) 2009 by Michael Schwern . 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) 2009 by Michael Schwern . 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 utf8-all-0.017/dist.ini0000644000175000017500000000052512621557530013265 0ustar mikemikename = utf8-all author = Michael Schwern author = Mike Doherty license = Perl_5 copyright_holder = Michael Schwern ; he wrote it, not me copyright_year = 2009 [@Author::DOHERTY] has_version = 0 max_target_perl = v5.10.0 utf8-all-0.017/Build.PL0000644000175000017500000000330112621557530013110 0ustar mikemike # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.036. use strict; use warnings; use Module::Build 0.28; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.28" }, "configure_requires" => { "Module::Build" => "0.28", "perl" => "5.010" }, "dist_abstract" => "turn on Unicode - all of it", "dist_author" => [ "Michael Schwern ", "Mike Doherty " ], "dist_name" => "utf8-all", "dist_version" => "0.017", "license" => "perl", "module_name" => "utf8::all", "recommends" => {}, "recursive_test_files" => 1, "requires" => { "Encode" => 0, "Import::Into" => 0, "Symbol" => 0, "charnames" => 0, "feature" => 0, "open" => 0, "parent" => 0, "perl" => "5.010", "strict" => 0, "utf8" => 0, "warnings" => 0 }, "script_files" => [], "test_requires" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "PerlIO" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "Test::Warn" => 0, "autodie" => 0, "constant" => 0, "perl" => "5.010", "version" => "0.77" } ); my %fallback_build_requires = ( "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Module::Build" => "0.28", "PerlIO" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "Test::Warn" => 0, "autodie" => 0, "constant" => 0, "perl" => "5.010", "version" => "0.77" ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; utf8-all-0.017/lib/0000775000175000017500000000000012621557530012367 5ustar mikemikeutf8-all-0.017/lib/utf8/0000775000175000017500000000000012621557530013255 5ustar mikemikeutf8-all-0.017/lib/utf8/all.pm0000644000175000017500000001717012621557530014367 0ustar mikemikepackage utf8::all; use strict; use warnings; use 5.010; # state # ABSTRACT: turn on Unicode - all of it our $VERSION = '0.017'; # VERSION use Import::Into; use parent qw(Encode charnames utf8 open warnings feature); use Symbol qw(qualify_to_ref); # Holds the pointers to the original version of redefined functions state %_orig_functions; sub import { # Enable features/pragmas in calling package my $target = caller; 'utf8'->import::into($target); 'open'->import::into($target, qw{:encoding(UTF-8) :std}); 'charnames'->import::into($target, qw{:full :short}); 'warnings'->import::into($target, qw{FATAL utf8}); 'feature'->import::into($target, qw{unicode_strings}) if $^V >= v5.11.0; 'feature'->import::into($target, qw{unicode_eval fc}) if $^V >= v5.16.0; unless ($^O =~ /MSWin32|cygwin|dos|os2/) { no strict qw(refs); ## no critic (TestingAndDebugging::ProhibitNoStrict) no warnings qw(redefine); # Replace readdir with utf8 aware version *{$target . '::readdir'} = \&_utf8_readdir; # Replace readdir with utf8 aware version *{$target . '::readlink'} = \&_utf8_readlink; # Replace glob with utf8 aware version *{$target . '::glob'} = \&_utf8_glob; # Set compiler hint to encode/decode in the redefined functions $^H{'utf8::all'} = 1; } # Make @ARGV utf-8 when called from the main package, unless perl was launched # with the -CA flag as this already has @ARGV decoded automatically. # -CA is active if the the fifth bit (32) of the ${^UNICODE} variable is set. # (see perlrun on the -C command switch for details about ${^UNICODE}) if (!(${^UNICODE} & 32)) { state $have_encoded_argv = 0; if ($target eq 'main' && !$have_encoded_argv++) { $_ = Encode::decode('UTF-8' ,$_) for @ARGV; } } return; } sub unimport { ## no critic (Subroutines::ProhibitBuiltinHomonyms) # Disable features/pragmas in calling package # Note: Does NOT undo the effect on @ARGV, # nor on the STDIN, STDOUT, and STDERR file handles! # These effects are always "global". my $target = caller; 'utf8'->unimport::out_of($target); 'open'->import::into($target, qw{IO :bytes}); $^H{'utf8::all'} = 0; # Reset compiler hint return; } sub _utf8_readdir(*) { ## no critic (Subroutines::ProhibitSubroutinePrototypes) my $pre_handle = shift; my $handle = ref($pre_handle) ? $pre_handle : qualify_to_ref($pre_handle, caller); my $hints = (caller 0)[10]; if (not $hints->{'utf8::all'}) { return CORE::readdir($handle); } elsif (wantarray) { return map { Encode::decode('UTF-8' ,$_) } CORE::readdir($handle); } else { return Encode::decode('UTF-8', CORE::readdir($handle)); } } sub _utf8_readlink(_) { ## no critic (Subroutines::ProhibitSubroutinePrototypes) my $arg = shift; my $hints = (caller 0)[10]; if (not $hints->{'utf8::all'}) { return CORE::readlink($arg); } else { return Encode::decode('UTF-8', CORE::readlink(Encode::encode('UTF-8', $arg))); } } sub _utf8_glob { my $arg = $_[0]; # Making this a lexical somehow is important! my $hints = (caller 0)[10]; if (not $hints->{'utf8::all'}) { return CORE::glob($arg); } else { $arg = Encode::encode('UTF-8', $arg); if (wantarray) { return map { Encode::decode('UTF-8' ,$_) } CORE::glob($arg); } else { return Encode::decode('UTF-8', CORE::glob($arg)); } } } 1; __END__ =pod =encoding UTF-8 =head1 NAME utf8::all - turn on Unicode - all of it =head1 VERSION version 0.017 =head1 SYNOPSIS use utf8::all; # Turn on UTF-8, all of it. open my $in, '<', 'contains-utf8'; # UTF-8 already turned on here print length 'føø bār'; # 7 UTF-8 characters my $utf8_arg = shift @ARGV; # @ARGV is UTF-8 too (only for main) =head1 DESCRIPTION The C pragma tells the Perl parser to allow UTF-8 in the program text in the current lexical scope. This also means that you can now use literal Unicode characters as part of strings, variable names, and regular expressions. C goes further: =over 4 =item * L|charnames> are imported so C<\N{...}> sequences can be used to compile Unicode characters based on names. =item * On Perl C or higher, the C is enabled. =item * C and C are enabled on Perl C<5.16.0> and higher. =item * Filehandles are opened with UTF-8 encoding turned on by default (including STDIN, STDOUT, STDERR). Meaning that they automatically convert UTF-8 octets to characters and vice versa. If you I want UTF-8 for a particular filehandle, you'll have to set C. =item * C<@ARGV> gets converted from UTF-8 octets to Unicode characters (when C is used from the main package). This is similar to the behaviour of the C<-CA> perl command-line switch (see L). =item * C, C, C (including the C and backtick operators), and L|perlfunc/glob> (including the C<< <> >> operator) now all work with and return Unicode characters instead of (UTF-8) octets. =back =head2 Lexical scope The pragma is lexically-scoped, so you can do the following if you had some reason to: { use utf8::all; open my $out, '>', 'outfile'; my $utf8_str = 'føø bār'; print length $utf8_str, "\n"; # 7 print $out $utf8_str; # out as utf8 } open my $in, '<', 'outfile'; # in as raw my $text = do { local $/; <$in>}; print length $text, "\n"; # 10, not 7! Instead of lexical scoping, you can also use C to turn off the effects. Note that the effect on C<@ARGV> and the C, C, and C file handles is always global! =head1 SEE ALSO =over 4 =item * L for fully utf-8 aware File::Find functions. =item * L for fully utf-8 aware Cwd functions. =back =head1 INTERACTION WITH AUTODIE If you use L, which is a great idea, you need to use at least version B<2.12>, released on L. Otherwise, autodie obliterates the IO layers set by the L pragma. See L and L. =head1 AVAILABILITY The project homepage is L. The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit L to find a CPAN site near you, or see L. =head1 SOURCE The development version is on github at L and may be cloned from L =head1 BUGS AND LIMITATIONS You can make new bug reports, and view existing ones, through the web interface at L. =head1 COMPATIBILITY The filesystems of Dos, Windows, and OS/2 do not (fully) support UTF-8. The C and C functions and C operators will therefore not be replaced on these systems. =head1 AUTHORS =over 4 =item * Michael Schwern =item * Mike Doherty =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009 by Michael Schwern . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut utf8-all-0.017/xt/0000775000175000017500000000000012621557530012254 5ustar mikemikeutf8-all-0.017/xt/author/0000775000175000017500000000000012621557530013556 5ustar mikemikeutf8-all-0.017/xt/author/critic.t0000644000175000017500000000043512621557530015220 0ustar mikemike#!perl use strict; use warnings; use Test::More; use English qw(-no_match_vars); eval "use Test::Perl::Critic"; plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc"; all_critic_ok(); utf8-all-0.017/xt/author/no-tabs.t0000644000175000017500000000111012621557530015275 0ustar mikemikeuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/utf8/all.pm', 't/00-compile.t', 't/ARGV.t', 't/ARGV_nonmain.t', 't/ARGV_twice.t', 't/FATAL_utf8.t', 't/autodie.t', 't/charnames.t', 't/fc.t', 't/glob.t', 't/lexical-again.t', 't/lexical.t', 't/open.t', 't/readdir.t', 't/readlink.t', 't/readpipe.t', 't/unicode_eval.t', 't/unicode_strings.t', 't/utf8.t' ); notabs_ok($_) foreach @files; done_testing; utf8-all-0.017/xt/author/eol.t0000644000175000017500000000114212621557530014516 0ustar mikemikeuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.18 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/utf8/all.pm', 't/00-compile.t', 't/ARGV.t', 't/ARGV_nonmain.t', 't/ARGV_twice.t', 't/FATAL_utf8.t', 't/autodie.t', 't/charnames.t', 't/fc.t', 't/glob.t', 't/lexical-again.t', 't/lexical.t', 't/open.t', 't/readdir.t', 't/readlink.t', 't/readpipe.t', 't/unicode_eval.t', 't/unicode_strings.t', 't/utf8.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; utf8-all-0.017/xt/release/0000775000175000017500000000000012621557530013674 5ustar mikemikeutf8-all-0.017/xt/release/unused-vars.t0000644000175000017500000000036212621557530016334 0ustar mikemike#!perl use Test::More 0.96 tests => 1; eval { require Test::Vars }; SKIP: { skip 1 => 'Test::Vars required for testing for unused vars' if $@; Test::Vars->import; subtest 'unused vars' => sub { all_vars_ok(); }; }; utf8-all-0.017/xt/release/portability.t0000644000175000017500000000027712621557530016427 0ustar mikemike#!perl use strict; use warnings; use Test::More; eval 'use Test::Portability::Files'; plan skip_all => 'Test::Portability::Files required for testing portability' if $@; run_tests(); utf8-all-0.017/xt/release/kwalitee.t0000644000175000017500000000027512621557530015670 0ustar mikemike# this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.11 use strict; use warnings; use Test::More 0.88; use Test::Kwalitee 1.21 'kwalitee_ok'; kwalitee_ok(); done_testing; utf8-all-0.017/xt/release/pod-linkcheck.t0000644000175000017500000000053712621557530016577 0ustar mikemike#!perl use strict; use warnings; use Test::More; foreach my $env_skip ( qw( SKIP_POD_LINKCHECK ) ){ plan skip_all => "\$ENV{$env_skip} is set, skipping" if $ENV{$env_skip}; } eval "use Test::Pod::LinkCheck"; if ( $@ ) { plan skip_all => 'Test::Pod::LinkCheck required for testing POD'; } else { Test::Pod::LinkCheck->new->all_pod_ok; } utf8-all-0.017/xt/release/dist-manifest.t0000644000175000017500000000023012621557530016621 0ustar mikemike#!perl use Test::More; eval "use Test::DistManifest"; plan skip_all => "Test::DistManifest required for testing the manifest" if $@; manifest_ok(); utf8-all-0.017/xt/release/mojibake.t0000644000175000017500000000040612621557530015640 0ustar mikemike#!perl use strict; use warnings qw(all); use Test::More; ## no critic (ProhibitStringyEval, RequireCheckingReturnValueOfEval) eval q(use Test::Mojibake); plan skip_all => q(Test::Mojibake required for source encoding testing) if $@; all_files_encoding_ok(); utf8-all-0.017/xt/release/distmeta.t0000644000175000017500000000017212621557530015671 0ustar mikemike#!perl # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use Test::CPAN::Meta; meta_yaml_ok(); utf8-all-0.017/xt/release/cpan-changes.t0000644000175000017500000000026312621557530016407 0ustar mikemike#!perl use strict; use warnings; use Test::More 0.96 tests => 2; use_ok('Test::CPAN::Changes'); subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; done_testing(); utf8-all-0.017/xt/release/minimum-version.t0000644000175000017500000000027012621557530017214 0ustar mikemike#!perl use Test::More; eval "use Test::MinimumVersion"; plan skip_all => "Test::MinimumVersion required for testing minimum versions" if $@; all_minimum_version_ok( qq{v5.10.0} ); utf8-all-0.017/xt/release/meta-json.t0000644000175000017500000000006412621557530015754 0ustar mikemike#!perl use Test::CPAN::Meta::JSON; meta_json_ok(); utf8-all-0.017/xt/release/synopsis.t0000644000175000017500000000006012621557530015742 0ustar mikemike#!perl use Test::Synopsis; all_synopsis_ok(); utf8-all-0.017/xt/release/pod-coverage.t0000644000175000017500000000033412621557530016432 0ustar mikemike#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); utf8-all-0.017/xt/release/pod-syntax.t0000644000175000017500000000022012621557530016157 0ustar mikemike#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; use Test::Pod 1.41; all_pod_files_ok(); utf8-all-0.017/xt/release/test-version.t0000644000175000017500000000060712621557530016524 0ustar mikemikeuse strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 1.02 use Test::Version; my @imports = qw( version_all_ok ); my $params = { is_strict => 0, has_version => 0, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; utf8-all-0.017/t/0000775000175000017500000000000012621557530012064 5ustar mikemikeutf8-all-0.017/t/glob.t0000644000175000017500000000257712621557530013205 0ustar mikemike#!perl use strict; use warnings; use Test::More 0.96; use Encode qw/decode FB_CROAK/; plan skip_all => "Skipped: $^O does not have proper utf-8 file system support" if $^O =~ /MSWin32|cygwin|dos|os2/; mkdir "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}" or die "Couldn't create directory corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}: $!" unless -d "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}"; plan tests => 1; subtest glob => sub { plan tests => 14; my @globs = (glob("corpus/*"), glob("corpus/{testfile,\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}}"), ); my $count = 0; while (my $glob = glob("corpus/*")) { push(@globs, $glob); $count++; } @globs = sort @globs; my @utf8_globs; my $utf8_count = 0; { use utf8::all; @utf8_globs = (glob("corpus/*"), glob("corpus/{testfile,\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}}"), ); while (my $glob = glob("corpus/*")) { push(@utf8_globs, $glob); $utf8_count++; } } @utf8_globs = sort @utf8_globs; is $count => 2, "glob: scalar version"; is $utf8_count => 2, "utf8_glob: scalar version"; for (my $i=0; $i<4; $i++) { is $globs[$i] => $utf8_globs[$i]; isnt $globs[4+$i] => $utf8_globs[4+$i]; is decode('UTF-8', $globs[4+$i], FB_CROAK) => $utf8_globs[4+$i]; } }; utf8-all-0.017/t/readdir.t0000644000175000017500000000353212621557530013664 0ustar mikemike#!perl use strict; use warnings; use Test::More 0.96; use Encode qw/decode FB_CROAK/; plan skip_all => "Skipped: $^O does not have proper utf-8 file system support" if $^O =~ /MSWin32|cygwin|dos|os2/; mkdir "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}" or die "Couldn't create directory corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}: $!" unless -d "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}"; plan tests => 3; subtest utf8 => sub { plan tests => 3; opendir my $dh, 'corpus' or die "Couldn't open directory 'corpus'"; my @files = sort grep { $_ ne '.' and $_ ne '..' } readdir $dh; my @utf8_files; { rewinddir $dh; use utf8::all; @utf8_files = sort grep { $_ ne '.' and $_ ne '..' } readdir $dh; } closedir $dh; is_deeply \@utf8_files, [sort "\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"]; is $files[0] => $utf8_files[0]; isnt $files[1] => $utf8_files[1]; }; subtest context => sub { plan tests => 1; opendir my $dh, 'corpus' or die "Couldn't open directory 'corpus'"; use utf8::all; my $core = CORE::readdir $dh; rewinddir $dh; my $utf8 = readdir $dh; rewinddir $dh; is $utf8 => decode('UTF-8', $core, FB_CROAK) or diag "$utf8 : $core"; closedir $dh; }; subtest package_var => sub { plan tests => 3; opendir DH, 'corpus' or die "Couldn't open directory 'corpus'"; my @files = sort grep { $_ ne '.' and $_ ne '..' } eval { readdir DH; }; my @utf8_files; { rewinddir DH; use utf8::all; @utf8_files = sort grep { $_ ne '.' and $_ ne '..' } readdir DH; } closedir DH; is_deeply \@utf8_files, [sort "\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"]; is $files[0] => $utf8_files[0]; is decode('UTF-8', $files[1], FB_CROAK) => $utf8_files[1]; }; utf8-all-0.017/t/lexical-again.t0000644000175000017500000000442712621557530014754 0ustar mikemike#!perl # no utf8::all should disable its effects lexically # Note: Changes to @ARGV, STDIN, STDOU, and STDERR are always global! use Test::More tests => 17; use PerlIO; my $expected_unicode = "\x{30c6}\x{30b9}\x{30c8}"; # Unicode characters my $expected_utf8 = "\x{e3}\x{83}\x{86}\x{e3}\x{82}\x{b9}\x{e3}\x{83}\x{88}"; # UTF-8 encoded octets use utf8::all; is "テスト" => $expected_unicode, 'Literal string should be characters under utf8::all'; { no utf8::all; is "テスト" => $expected_utf8, 'Literal string should be utf-8 encoded octets without utf8::all'; # Test the standard handles and all newly opened handles are not utf8 ok((open my $out, ">", "lexical_octets.tmp"), 'open file for writing without utf8::all'); END { unlink "lexical_octets.tmp" } ok((open my $in, '<', 'corpus/testfile'), 'open file for reading without utf8::all'); my $contents = do { local $/; <$in>}; is $contents, "$expected_utf8\n", 'octets retreived OK'; my %handles = ( IN => $in, OUT => $out, ); for my $fh (keys %handles) { my @layers = PerlIO::get_layers($handles{$fh}); ok(!grep(m/utf8/, @layers), "$fh: utf8 does not appear in the perlio layers") or diag explain { $fh => \@layers }; ok(!grep(m/utf-8-strict/, @layers), "$fh: utf-8-strict does not appear in the perlio layers") or diag explain { $fh => \@layers }; } } is "テスト" => $expected_unicode, 'Literal string should be characters under utf8::all (again)'; # Test the standard handles and all newly opened handles are utf8 (again) ok((open my $out, ">", "lexical_unicode.tmp"), 'open file for writing with utf8::all'); END { unlink "lexical_unicode.tmp" } ok((open my $in, '<', 'corpus/testfile'), 'open file for reading with utf8::all'); my $contents = do { local $/; <$in>}; is $contents, "$expected_unicode\n", 'unicode retrieved OK'; my %handles = ( IN => $in, OUT => $out, ); for my $fh (keys %handles) { my @layers = PerlIO::get_layers($handles{$fh}); ok(grep(m/utf8/, @layers), "$fh: utf8 does appear in the perlio layers") or diag explain { $fh => \@layers }; ok(grep(m/utf-8-strict/, @layers), "$fh: utf-8-strict does appear in the perlio layers") or diag explain { $fh => \@layers }; } utf8-all-0.017/t/ARGV_twice.t0000644000175000017500000000147512621557530014210 0ustar mikemike#!perl # Test that utf8::all doesn't double encode @ARGV [perl5i github 176] BEGIN { # String literals are still utf-8 encoded octets here! @ARGV = qw(føø bar bāz テスト); if (${^UNICODE} & 32) { # If we run with the Perl Unicode flag to automatically # convert the command-line arguments to unicode characters, # we need to do so here too! require Encode; $_ = Encode::decode('UTF-8' ,$_) for @ARGV; } } { package Foo; use utf8::all; } { use utf8::all; } use utf8::all; use Test::More tests => 1; # føø bar bāz テスト still intact as unicode characters is_deeply \@ARGV => [ "\x{66}\x{f8}\x{f8}", "\x{62}\x{61}\x{72}", "\x{62}\x{101}\x{7a}", "\x{30c6}\x{30b9}\x{30c8}" ], '@ARGV as unicode characters instead of utf-8 octets'; utf8-all-0.017/t/open.t0000644000175000017500000000076712621557530013222 0ustar mikemike#!perl # Test opening an actual file use utf8::all; use PerlIO; use Test::More tests => 4; ok open my $in, '<', 'corpus/testfile'; my @layers = PerlIO::get_layers($in); ok(grep(m/utf8/, @layers), 'utf8 appears in the perlio layers') or diag explain { $fh => \@layers }; ok(grep(m/utf-8-strict/, @layers), 'utf-8-strict appears in the perlio layers') or diag explain { $fh => \@layers }; my $contents = do { local $/; <$in>}; is $contents, "\x{30c6}\x{30b9}\x{30c8}\n", 'unicode retrieved OK'; utf8-all-0.017/t/unicode_strings.t0000644000175000017500000000443512621557530015454 0ustar mikemike#!perl # utf8::all should turn on feature qw(unicode_strings) use strict; use warnings; use Config; use Test::More; plan $^V >= v5.14.0 ? (tests => 13) : (skip_all => q/character set modifiers aren't available until 5.14.0/); use constant HAVE_LOCALE => $Config{i_locale}; my $code = <<'TEST_CODE'; # Straight out of t/re/pat.t { # Test that charset modifier work, and are interpolated is(qr/\b\v$/, '(?^:\b\v$)', 'Verify no locale, no unicode_strings gives default modifier'); is(qr/(?l:\b\v$)/, '(?^:(?l:\b\v$))', 'Verify infix l modifier compiles'); is(qr/(?u:\b\v$)/, '(?^:(?u:\b\v$))', 'Verify infix u modifier compiles'); is(qr/(?l)\b\v$/, '(?^:(?l)\b\v$)', 'Verify (?l) compiles'); is(qr/(?u)\b\v$/, '(?^:(?u)\b\v$)', 'Verify (?u) compiles'); my $dual = qr/\b\v$/; use locale; my $locale = qr/\b\v$/; SKIP: { skip "No locale on this system, /l flag not present", 1 if !HAVE_LOCALE; is($locale, '(?^l:\b\v$)', 'Verify has l modifier when compiled under use locale'); } no locale; use utf8::all; # use utf8::all instead of feature qw(unicode_strings); my $unicode = qr/\b\v$/; is($unicode, '(?^u:\b\v$)', 'Verify has u modifier when compiled under unicode_strings'); is(qr/abc$dual/, '(?^u:abc(?^:\b\v$))', 'Verify retains d meaning when interpolated under locale'); SKIP: { skip "No locale on this system, /l flag not present", 1 if !HAVE_LOCALE; is(qr/abc$locale/, '(?^u:abc(?^l:\b\v$))', 'Verify retains l when interpolated under unicode_strings'); } no feature 'unicode_strings'; SKIP: { skip "No locale on this system, /l flag not present", 1 if !HAVE_LOCALE; is(qr/abc$locale/, '(?^:abc(?^l:\b\v$))', 'Verify retains l when interpolated outside locale and unicode strings'); } is(qr/def$unicode/, '(?^:def(?^u:\b\v$))', 'Verify retains u when interpolated outside locale and unicode strings'); use locale; SKIP: { skip "No locale on this system, /l flag not present", 2 if !HAVE_LOCALE; is(qr/abc$dual/, '(?^l:abc(?^:\b\v$))', 'Verify retains d meaning when interpolated under locale'); is(qr/abc$unicode/, '(?^l:abc(?^u:\b\v$))', 'Verify retains u when interpolated under locale'); } } TEST_CODE eval $code;utf8-all-0.017/t/readlink.t0000644000175000017500000000225212621557530014041 0ustar mikemike#!perl use strict; use warnings; use Test::More 0.96; use Encode qw/find_encoding FB_CROAK LEAVE_SRC/; plan skip_all => "Skipped: $^O does not have proper utf-8 file system support" if $^O =~ /MSWin32|cygwin|dos|os2/; mkdir "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}" or die "Couldn't create directory corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}: $!" unless -d "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}"; symlink "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testlink.tmp" or die "Couldn't create symlink from testlink.tmp: $!"; END { unlink("testlink.tmp") or die "Unable to remove testlink.tmp: $!" if -l "testlink.tmp"; } my $_UTF8 = find_encoding('UTF-8'); plan tests => 3; my $linkdest = readlink('testlink.tmp'); my $utf8_linkdest; { use utf8::all; $utf8_linkdest = readlink('testlink.tmp'); } is $utf8_linkdest => "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", 'utf8 linkdest should be as expected'; is $linkdest => $_UTF8->encode($utf8_linkdest, FB_CROAK | LEAVE_SRC), 'encoded utf8 linkdest matches non-utf8'; is $_UTF8->decode($linkdest, FB_CROAK | LEAVE_SRC) => $utf8_linkdest, 'utf8 linkdest matches decoded non-utf8'; utf8-all-0.017/t/autodie.t0000644000175000017500000000317112621557530013703 0ustar mikemike#!perl use strict; use warnings; use version 0.77; use Test::More 0.96; use Test::Fatal; plan skip_all => "Skipped: $^O does not have proper utf-8 file system support" if $^O =~ /MSWin32|cygwin|dos|os2/; mkdir "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}" or die "Couldn't create directory corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}: $!" unless -d "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}"; if ( eval { require autodie; 1 } ) { diag <parse($autodie::VERSION) <= version->parse(2.11); plan tests => 2; } else { plan skip_all => "autodie is required for these tests (but is not a prerequisite)"; } no autodie; subtest 'autodie first' => sub { plan tests => 2; use autodie; use utf8::all; opendir my $dh, 'corpus'; my @files = sort grep { !m{^\.} } readdir $dh; closedir $dh; is_deeply \@files, [sort "\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"]; my $exception = exception { opendir my $no_dh, 'nonexistent' }; like $exception => qr/^\QCan't opendir/; }; subtest 'autodie last' => sub { plan tests => 2; use utf8::all; use autodie; opendir my $dh, 'corpus'; my @files = sort grep { !m{^\.} } readdir $dh; closedir $dh; is_deeply \@files, [ sort "\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}", "testfile"]; my $exception = exception { opendir my $no_dh, 'nonexistent' }; like $exception, qr/^\QCan't opendir/; }; utf8-all-0.017/t/ARGV_nonmain.t0000644000175000017500000000105612621557530014527 0ustar mikemike#!perl # Test that utf8::all makes @ARGV utf8 (but not when not loaded from main) BEGIN { # String literals are still utf-8 encoded octets here! @ARGV = qw(føø bar bāz テスト); } package not_main; use utf8::all; use Test::More tests => 1; is_deeply \@ARGV => [ # føø bar bāz テスト still as utf-8 encoded octets "\x{66}\x{c3}\x{b8}\x{c3}\x{b8}", "\x{62}\x{61}\x{72}", "\x{62}\x{c4}\x{81}\x{7a}", "\x{e3}\x{83}\x{86}\x{e3}\x{82}\x{b9}\x{e3}\x{83}\x{88}", ], 'non main package: @ARGV still as utf-8 encoded octets'; utf8-all-0.017/t/unicode_eval.t0000644000175000017500000000134112621557530014703 0ustar mikemike#!perl # utf8::all should turn on feature qw(unicode_strings) use strict; use warnings; use Test::More; plan $^V >= v5.16.0 ? (tests => 5) : (skip_all => q/Can't enable unicode_eval on perl < 5.16.0/); # straight out of t/uni/eval.t use utf8::all; { my $w; $SIG{__WARN__} = sub { $w = shift }; use utf8; my $prog = "qq!\x{f9}!"; eval $prog; ok !$w; $w = ""; utf8::upgrade($prog); eval $prog; is $w, ''; } { use utf8; isnt eval "q!\360\237\220\252!", eval "q!\x{1f42a}!"; } { no utf8; #Let's make real sure. my $not_utf8 = "q!\343\203\213!"; isnt eval $not_utf8, eval "q!\x{30cb}!"; { use utf8; isnt eval $not_utf8, eval "q!\x{30cb}!"; } }utf8-all-0.017/t/fc.t0000644000175000017500000000077012621557530012643 0ustar mikemike#!perl # utf8::all should turn on feature qw(unicode_strings) use strict; use warnings; use Test::More; plan $^V >= v5.16.0 ? (tests => 3) : (skip_all => q/Can't enable fc on perl < 5.16.0/); { no warnings qw(syntax); eval q/fc 'ABC' eq fc 'abc';/; ok $@, 'Got an error using fc without utf8::all...'; like $@ => qr/^syntax error/, '...and the error was a syntax error' or diag $@; } eval q/ use utf8::all; fc 'XYZ' eq fc 'xyz'; /; ok !$@, 'no error with utf8::all' or diag $@;utf8-all-0.017/t/00-compile.t0000644000175000017500000000211412621557530014112 0ustar mikemikeuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.052 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'utf8/all.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; utf8-all-0.017/t/charnames.t0000644000175000017500000000057112621557530014213 0ustar mikemike#!perl # Test that utf8::all imports charnames for \N use utf8::all; use Test::More tests => 3; is_deeply "\N{GREEK SMALL LETTER SIGMA} is called sigma.", "σ is called sigma.", ':full'; is_deeply "\N{greek:Sigma}", "Σ", ':short'; is_deeply charnames::vianame("GOTHIC LETTER AHSA"), 66352, 'charnames::vianame'; utf8-all-0.017/t/lexical.t0000644000175000017500000000131712621557530013672 0ustar mikemike#!perl # utf8::all should have lexical effect (except for @ARGV!) use Test::More tests => 4; my $expected_unicode = "\x{30c6}\x{30b9}\x{30c8}"; # Unicode characters my $expected_utf8 = "\x{e3}\x{83}\x{86}\x{e3}\x{82}\x{b9}\x{e3}\x{83}\x{88}"; # UTF-8 encoded octets is "テスト" => $expected_utf8, 'Literal string should be utf-8 encoded octets without utf8::all'; { use utf8::all; is "テスト" => $expected_unicode, 'Literal string should be characters under utf8::all'; } is "テスト" => $expected_utf8, 'Literal string should be utf-8 encoded octets without utf8::all (again)'; use utf8::all; is "テスト" => $expected_unicode, 'Literal string should be characters under utf8::all (again)'; utf8-all-0.017/t/FATAL_utf8.t0000644000175000017500000000161112621557530014043 0ustar mikemike#!perl use strict; use warnings; use Test::More tests => 3; use Test::Warn; use warnings FATAL=>'utf8'; # Fatal warning warning_like { eval q/open my $out, '>', \my $mem; binmode $out, ':raw'; print $out "\x{FACE}"/; warn $@ } qr/Wide character/, # warning categories only work for non-fatal warnings 'Fatal "Wide character" warning' or diag $@; # Non-fatal warning warning_like { open my $out, '>', \my $mem; binmode $out, ':raw'; use warnings NONFATAL => 'utf8'; # downgrade to non-fatal utf8 warnings print $out "\x{FACE}" } 'utf8',#qr/Wide character/, 'Non-fatal "Wide character" warning' or diag $@; warning_is { open my $out, '>', \my $mem; binmode $out, ':raw'; no warnings FATAL => 'utf8'; # disable fatal utf8 warnings print $out "\x{FACE}"; } [], 'No "Wide character" warning';utf8-all-0.017/t/readpipe.t0000644000175000017500000000330512621557530014041 0ustar mikemike#!perl use strict; use warnings; use Test::More 0.96; use Encode qw/find_encoding FB_CROAK LEAVE_SRC/; plan skip_all => "Skipped: $^O does not have proper utf-8 file system support" if $^O =~ /MSWin32|cygwin|dos|os2/; mkdir "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}" or die "Couldn't create directory corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}: $!" unless -d "corpus/\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}"; my $_UTF8 = find_encoding('UTF-8'); plan tests => 3*3; my $cmd = 'ls -1 corpus'; my $expected = "testfile\n\x{307f}\x{304b}\x{3061}\x{3083}\x{3093}\n"; my $result; my $utf8_result; sub sort_res { return join("\n", sort(split("\n", shift))); } sub test_res { my $test = shift; my $result = shift; my $utf8_result = shift; is sort_res($utf8_result) => sort_res($expected), "$test utf8 result should be as expected"; SKIP: { # If we have the Perl Unicode flag set that adds the UTF-8 layer, # we need to skip these tests. skip 'Perl Unicode flag set that always adds UTF-8 layer to input', 2 if (${^UNICODE} & 8); is $result => $_UTF8->encode($utf8_result, FB_CROAK | LEAVE_SRC), "$test encoded utf8 result matches non-utf8"; is $_UTF8->decode($result, FB_CROAK | LEAVE_SRC) => $utf8_result, "$test utf8 result matches decoded non-utf8"; } } # readpipe $result = readpipe($cmd); { use utf8::all; $utf8_result = readpipe($cmd); } test_res('readpipe', $result, $utf8_result); # Backtick $result = `$cmd`; { use utf8::all; $utf8_result = `$cmd`; } test_res('Backtick', $result, $utf8_result); # qx $result = qx{$cmd}; { use utf8::all; $utf8_result = qx{$cmd}; } test_res('qx', $result, $utf8_result); utf8-all-0.017/t/utf8.t0000644000175000017500000000301112621557530013130 0ustar mikemike#!perl # utf8::all turns on utf8 use strict; use warnings; use PerlIO; use Test::More; # Test with it on { use utf8::all; is length "utf8::all is MËTÁŁ" => 18, 'unicode string is characters'; # Test the standard handles and all newly opened handles are utf8 ok((open my $test_fh, ">", "perlio_test"), 'open file for writing with utf8::all'); END { unlink "perlio_test" } for my $fh (*STDOUT, *STDIN, *STDERR, $test_fh) { my @layers = PerlIO::get_layers($fh); ok(grep(m/utf8/, @layers), 'utf8 appears in the perlio layers') or diag explain { $fh => \@layers }; ok(grep(m/utf-8-strict/, @layers), 'utf-8-strict appears in the perlio layers') or diag explain { $fh => \@layers }; } } # And off { is length "utf8::all is MËTÁŁ" => 21, 'unicode string is octets'; ok((open my $test_fh, ">", "perlio_test2"), 'open file for writing with utf8::all'); END { unlink "perlio_test2" } my @layers = PerlIO::get_layers($test_fh); SKIP: { # If we have the Perl Unicode flag set that adds the UTF-8 layer, # we need to skip this test. skip 'Perl Unicode flag set that always adds UTF-8 layer to output', 1 if (${^UNICODE} & 16); ok( !grep(/utf8/, @layers), q{utf8 doesn't appear in perlio layers}) or diag explain { $test_fh => \@layers }; } ok( !grep(m/utf-8-strict/, @layers), q{utf-8-strict doesn't appear in the perlio layers}) or diag explain { $test_fh => \@layers }; } done_testing; utf8-all-0.017/t/ARGV.t0000644000175000017500000000133012621557530013003 0ustar mikemike#!perl # Test that utf8::all makes @ARGV utf8 BEGIN { # String literals are still utf-8 encoded octets here! @ARGV = qw(føø bar bāz テスト); if (${^UNICODE} & 32) { # If we run with the Perl Unicode flag to automatically # convert the command-line arguments to unicode characters, # we need to do so here too! require Encode; $_ = Encode::decode('UTF-8' ,$_) for @ARGV; } } use utf8::all; use Test::More tests => 1; # føø bar bāz テスト but now as unicode characters is_deeply \@ARGV => [ "\x{66}\x{f8}\x{f8}", "\x{62}\x{61}\x{72}", "\x{62}\x{101}\x{7a}", "\x{30c6}\x{30b9}\x{30c8}" ], '@ARGV as unicode characters instead of utf-8 octets'; utf8-all-0.017/MANIFEST.SKIP0000644000175000017500000000147012621557530013517 0ustar mikemike# Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. utf8-all-0.017/README.mkdn0000644000175000017500000001043312621557530013430 0ustar mikemike# NAME utf8::all - turn on Unicode - all of it # VERSION version 0.017 # SYNOPSIS use utf8::all; # Turn on UTF-8, all of it. open my $in, '<', 'contains-utf8'; # UTF-8 already turned on here print length 'føø bār'; # 7 UTF-8 characters my $utf8_arg = shift @ARGV; # @ARGV is UTF-8 too (only for main) # DESCRIPTION The `use utf8` pragma tells the Perl parser to allow UTF-8 in the program text in the current lexical scope. This also means that you can now use literal Unicode characters as part of strings, variable names, and regular expressions. `utf8::all` goes further: - [`charnames`](https://metacpan.org/pod/charnames) are imported so `\N{...}` sequences can be used to compile Unicode characters based on names. - On Perl `v5.11.0` or higher, the `use feature 'unicode_strings'` is enabled. - `use feature fc` and `use feature unicode_eval` are enabled on Perl `5.16.0` and higher. - Filehandles are opened with UTF-8 encoding turned on by default (including STDIN, STDOUT, STDERR). Meaning that they automatically convert UTF-8 octets to characters and vice versa. If you _don't_ want UTF-8 for a particular filehandle, you'll have to set `binmode $filehandle`. - `@ARGV` gets converted from UTF-8 octets to Unicode characters (when `utf8::all` is used from the main package). This is similar to the behaviour of the `-CA` perl command-line switch (see [perlrun](https://metacpan.org/pod/perlrun)). - `readdir`, `readlink`, `readpipe` (including the `qx//` and backtick operators), and [`glob`](https://metacpan.org/pod/perlfunc#glob) (including the `<>` operator) now all work with and return Unicode characters instead of (UTF-8) octets. ## Lexical scope The pragma is lexically-scoped, so you can do the following if you had some reason to: { use utf8::all; open my $out, '>', 'outfile'; my $utf8_str = 'føø bār'; print length $utf8_str, "\n"; # 7 print $out $utf8_str; # out as utf8 } open my $in, '<', 'outfile'; # in as raw my $text = do { local $/; <$in>}; print length $text, "\n"; # 10, not 7! Instead of lexical scoping, you can also use `no utf8::all` to turn off the effects. Note that the effect on `@ARGV` and the `STDIN`, `STDOUT`, and `STDERR` file handles is always global! # SEE ALSO - [File::Find::utf8](https://metacpan.org/pod/File::Find::utf8) for fully utf-8 aware File::Find functions. - [Cwd::utf8](https://metacpan.org/pod/Cwd::utf8) for fully utf-8 aware Cwd functions. # INTERACTION WITH AUTODIE If you use [autodie](https://metacpan.org/pod/autodie), which is a great idea, you need to use at least version **2.12**, released on [June 26, 2012](https://metacpan.org/source/PJF/autodie-2.12/Changes#L3). Otherwise, autodie obliterates the IO layers set by the [open](https://metacpan.org/pod/open) pragma. See [RT #54777](https://rt.cpan.org/Ticket/Display.html?id=54777) and [GH #7](https://github.com/doherty/utf8-all/issues/7). # AVAILABILITY The project homepage is [http://metacpan.org/release/utf8-all/](http://metacpan.org/release/utf8-all/). The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit [http://www.perl.com/CPAN/](http://www.perl.com/CPAN/) to find a CPAN site near you, or see [https://metacpan.org/module/utf8::all/](https://metacpan.org/module/utf8::all/). # SOURCE The development version is on github at [http://github.com/doherty/utf8-all](http://github.com/doherty/utf8-all) and may be cloned from [git://github.com/doherty/utf8-all.git](git://github.com/doherty/utf8-all.git) # BUGS AND LIMITATIONS You can make new bug reports, and view existing ones, through the web interface at [https://github.com/doherty/utf8-all/issues](https://github.com/doherty/utf8-all/issues). # COMPATIBILITY The filesystems of Dos, Windows, and OS/2 do not (fully) support UTF-8. The `readlink` and `readdir` functions and `glob` operators will therefore not be replaced on these systems. # AUTHORS - Michael Schwern - Mike Doherty # COPYRIGHT AND LICENSE This software is copyright (c) 2009 by Michael Schwern . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. utf8-all-0.017/Changes0000644000175000017500000000602312621557530013113 0ustar mikemikeRevision history for Perl module utf8-all 0.017 2015-11-13 - Tests now correctly handle the PERL_UNICODE env variable and the -C perl command-line flag. [gh-40; HayoBaan] - Implemented "no utf8::all" [gh-33; HayoBaan] - Corrected a number of tests [HayoBaan] - Added wrapper for readlink [gh-21; HayoBaan] - Added test for readpipe, qx, and backtick operator [HayoBaan] - Rewrote documentation [HayoBaan] 0.016 2015-01-08 - Not decoding @ARGV when perl is run with -CA [gh-32; HayoBaan] Thank you [saulery] for the tip! - Fixed exclusion of Windows platform [HayoBaan] - Excluding DOS and OS/2 platforms [HayoBaan] - Moved utf-8 aware implementation of File::Find and Cwd to their own module (File::Find::utf8 and Cwd::utf8) [HayoBaan] 0.015 2014-08-28 - Fixed changelog for 0.014 - Removed overly optimistic use of v5.20.0 syntax 0.014 2014-08-27 - Skip locale tests on systems without locale support [gh-27; Hugmeir] - Added wrapper for: [HayoBaan] - glob [HayoBaan] - File::Find::find, File::Find::finddepth, [HayoBaan] - Cwd::cwd Cwd::fastcwd Cwd::getcwd Cwd::fastgetcwd [HayoBaan] - Cwd::abs_path Cwd::realpath Cwd::fast_abs_path [HayoBaan] 0.013 2014-08-19 - Warn instead of bailing out of the test suite when autodie is old [gh-26, gh-22] - Only decoding @ARGV when called from the main package [gh-18] [HayoBaan] 0.012 2014-08-03 - Disable wrapping readdir on Windows [gh-17] - Don't ship files with names that aren't portable to Windows [gh-17] 0.011 2013-08-03 - Only decode readdir entries if utf8::all is in effect [leont] - Support direct dirhandles in readdir [leont] 0.010 2013-02-02 - Don't depend on localizable error strings 0.009 2012-10-27 - Don't depend on filesystem ordering [leont, GH #14] 0.008 2012-10-24 - Enable unicode_strings (see perldoc feature) [GH #2] - Enable unicode_eval (see perldoc feature) [GH #2] - Enable fc (see perldoc fc) [GH #2] - Wrap CORE::readdir to provide UTF-8 filenames [GH #11] 0.007 2012-08-01 - Use version.pm for comparing versions in the test suite - Better detection of warnings in t/FATAL_utf8.t - Don't fail the test suite if autodie is too old 0.006 2012-07-29 - Be less strict with detecting fatal UTF-8 error in test suite [GH #12] 0.005 2012-07-29 - Use Import::Into instead of home-grown "solution" [GH #10] - Don't permit running with autodie < 2.12, due to RT #54777 [GH #7] - Promote utf8 warnings to fatal errors [GH #1] 0.004 2012-01-04 - Fix test suite for less current versions of Perl [getty, doherty] 0.003 2011-12-21 - Internal refactoring - Load charnames [sartak] 0.002 2011-04-21 - Expand test suite slightly 0.001 2011-04-20 - Split code out of perl5i utf8-all-0.017/Makefile.PL0000644000175000017500000000354412621557530013577 0ustar mikemike# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.036. use strict; use warnings; use 5.010; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "turn on Unicode - all of it", "AUTHOR" => "Michael Schwern , Mike Doherty ", "BUILD_REQUIRES" => { "Module::Build" => "0.28" }, "CONFIGURE_REQUIRES" => { "Module::Build" => "0.28" }, "DISTNAME" => "utf8-all", "EXE_FILES" => [], "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.010", "NAME" => "utf8::all", "PREREQ_PM" => { "Encode" => 0, "Import::Into" => 0, "Symbol" => 0, "charnames" => 0, "feature" => 0, "open" => 0, "parent" => 0, "strict" => 0, "utf8" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "PerlIO" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "Test::Warn" => 0, "autodie" => 0, "constant" => 0, "version" => "0.77" }, "VERSION" => "0.017", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Encode" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Import::Into" => 0, "Module::Build" => "0.28", "PerlIO" => 0, "Symbol" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "Test::Warn" => 0, "autodie" => 0, "charnames" => 0, "constant" => 0, "feature" => 0, "open" => 0, "parent" => 0, "strict" => 0, "utf8" => 0, "version" => "0.77", "warnings" => 0 ); 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); utf8-all-0.017/corpus/0000775000175000017500000000000012621557530013134 5ustar mikemikeutf8-all-0.017/corpus/testfile0000644000175000017500000000001212621557530014665 0ustar mikemikeテスト utf8-all-0.017/META.json0000644000175000017500000000473212621557530013246 0ustar mikemike{ "abstract" : "turn on Unicode - all of it", "author" : [ "Michael Schwern ", "Mike Doherty " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.036, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "utf8-all", "no_index" : { "directory" : [ "corpus", "inc", "examples" ] }, "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.28" } }, "configure" : { "requires" : { "Module::Build" : "0.28", "perl" : "5.010" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Changes" : "0.19", "Test::CPAN::Meta" : "0", "Test::CPAN::Meta::JSON" : "0.16", "Test::EOL" : "0", "Test::Kwalitee" : "1.21", "Test::More" : "0.88", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Synopsis" : "0", "Test::Version" : "1" } }, "runtime" : { "requires" : { "Encode" : "0", "Import::Into" : "0", "Symbol" : "0", "charnames" : "0", "feature" : "0", "open" : "0", "parent" : "0", "perl" : "5.010", "strict" : "0", "utf8" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "PerlIO" : "0", "Test::Fatal" : "0", "Test::More" : "0.96", "Test::Warn" : "0", "autodie" : "0", "constant" : "0", "perl" : "5.010", "version" : "0.77" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/doherty/utf8-all/issues" }, "homepage" : "http://metacpan.org/release/utf8-all/", "repository" : { "type" : "git", "url" : "git://github.com/doherty/utf8-all.git", "web" : "https://github.com/doherty/utf8-all" } }, "version" : "0.017" } utf8-all-0.017/INSTALL0000644000175000017500000000164612621557530012657 0ustar mikemikeThis is the Perl distribution utf8-all. Installing utf8-all is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm utf8::all If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S utf8::all ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan utf8::all ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Build.PL % ./Build && ./Build test Then install it: % ./Build install If you are installing into a system-wide directory, you may need to run: % sudo ./Build install ## Documentation utf8-all documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc utf8::all utf8-all-0.017/MANIFEST0000644000175000017500000000153212621557530012751 0ustar mikemike# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.036. Build.PL Changes INSTALL LICENSE MANIFEST MANIFEST.SKIP META.json META.yml Makefile.PL README.mkdn corpus/testfile dist.ini lib/utf8/all.pm t/00-compile.t t/ARGV.t t/ARGV_nonmain.t t/ARGV_twice.t t/FATAL_utf8.t t/autodie.t t/charnames.t t/fc.t t/glob.t t/lexical-again.t t/lexical.t t/open.t t/readdir.t t/readlink.t t/readpipe.t t/unicode_eval.t t/unicode_strings.t t/utf8.t xt/author/critic.t xt/author/eol.t xt/author/no-tabs.t xt/release/cpan-changes.t xt/release/dist-manifest.t xt/release/distmeta.t xt/release/kwalitee.t xt/release/meta-json.t xt/release/minimum-version.t xt/release/mojibake.t xt/release/pod-coverage.t xt/release/pod-linkcheck.t xt/release/pod-syntax.t xt/release/portability.t xt/release/synopsis.t xt/release/test-version.t xt/release/unused-vars.t utf8-all-0.017/META.yml0000644000175000017500000000205112621557530013066 0ustar mikemike--- abstract: 'turn on Unicode - all of it' author: - 'Michael Schwern ' - 'Mike Doherty ' build_requires: File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Module::Build: '0.28' PerlIO: '0' Test::Fatal: '0' Test::More: '0.96' Test::Warn: '0' autodie: '0' constant: '0' perl: '5.010' version: '0.77' configure_requires: Module::Build: '0.28' perl: '5.010' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.036, 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: utf8-all no_index: directory: - corpus - inc - examples requires: Encode: '0' Import::Into: '0' Symbol: '0' charnames: '0' feature: '0' open: '0' parent: '0' perl: '5.010' strict: '0' utf8: '0' warnings: '0' resources: bugtracker: https://github.com/doherty/utf8-all/issues homepage: http://metacpan.org/release/utf8-all/ repository: git://github.com/doherty/utf8-all.git version: '0.017'