From dd36d13c89140c2d9d7954b9f1de583003154c13 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Sun, 7 Apr 2002 14:25:28 +0000 Subject: There was no nice way of getting in UTF-8 filenames: now one can use in the (new) three-arg form of readdir() and in File::Glob import a ":utf8" to transparently accept the filenames as Unicode. Note that only :utf8 is supported, not fancier stuff like :encoding(foobar) p4raw-id: //depot/perl@15776 --- ext/File/Glob/Glob.pm | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'ext/File/Glob/Glob.pm') diff --git a/ext/File/Glob/Glob.pm b/ext/File/Glob/Glob.pm index a704b567bb..4c34d380b0 100644 --- a/ext/File/Glob/Glob.pm +++ b/ext/File/Glob/Glob.pm @@ -31,6 +31,7 @@ use XSLoader (); GLOB_NOSPACE GLOB_QUOTE GLOB_TILDE + GLOB_UTF8 ); %EXPORT_TAGS = ( @@ -51,6 +52,7 @@ use XSLoader (); GLOB_NOSPACE GLOB_QUOTE GLOB_TILDE + GLOB_UTF8 glob bsd_glob ) ], @@ -62,10 +64,11 @@ sub import { require Exporter; my $i = 1; while ($i < @_) { - if ($_[$i] =~ /^:(case|nocase|globally)$/) { + if ($_[$i] =~ /^:(case|nocase|globally|utf8)$/) { splice(@_, $i, 1); $DEFAULT_FLAGS &= ~GLOB_NOCASE() if $1 eq 'case'; $DEFAULT_FLAGS |= GLOB_NOCASE() if $1 eq 'nocase'; + $DEFAULT_FLAGS |= GLOB_UTF8() if $1 eq 'utf8'; if ($1 eq 'globally') { local $^W; *CORE::GLOBAL::glob = \&File::Glob::csh_glob; @@ -203,15 +206,19 @@ File::Glob - Perl extension for BSD glob routine ## override the core glob (CORE::glob() does this automatically ## by default anyway, since v5.6.0) use File::Glob ':globally'; - my @sources = <*.{c,h,y}> + my @sources = <*.{c,h,y}>; ## override the core glob, forcing case sensitivity use File::Glob qw(:globally :case); - my @sources = <*.{c,h,y}> + my @sources = <*.{c,h,y}>; ## override the core glob forcing case insensitivity use File::Glob qw(:globally :nocase); - my @sources = <*.{c,h,y}> + my @sources = <*.{c,h,y}>; + + ## override the core glob forcing UTF-8 names + use File::Glob qw(:globally :utf8); + my @sources = <*.{c,h,y}>; =head1 DESCRIPTION @@ -321,6 +328,18 @@ order (case does not matter) rather than in ASCII order. =back +The following flag has been added in the Perl implementation for +Unicode compatibility: + +=over 4 + +=item C + +The filenames returned will be marked as being in UTF-8 encoding of +Unicode. Note that it is your responsibility to ascertain that the +filesystem you are globbing in returns valid UTF-8 filenames. +The encoding pragma affects this feature, see L. + =head1 DIAGNOSTICS bsd_glob() returns a list of matching paths, possibly zero length. If an -- cgit v1.2.1