in reply to Rename Windows files with Unicode chars
update: Example
#!/usr/bin/perl -- use strict; use warnings; use Win32::Unicode -native; listDir(); open my($fh), '>:encoding(UTF-8)', qq{I-\x{2665}-Perl} or die $!; print $fh qq{I-\x{2665}-Perl}; close $fh; listDir(); rename qq{I-\x{2665}-Perl}, 'I-love-Perl'; listDir(); unlink 'I-love-Perl'; sub listDir { my( $dir ) = grep defined, @_, '.'; my $wdir = Win32::Unicode::Dir->new( ); $wdir->open($dir) or die $!; for ($wdir->fetch) { next if /^\.{1,2}$/; my $full_path = "$dir/$_"; if (file_type('f', $full_path)) { print "f $_\n"; } elsif (file_type('d', $full_path)){ print "d $_\n"; } } $wdir->close or die $!; print "\n####\n\n"; } __END__
$ chcp 65001 Active code page: 65001 $ perl win32-unicode-native-to-ascii.pl f win32-unicode-native-to-ascii.pl #### f I-♥-Perl f win32-unicode-native-to-ascii.pl #### f I-love-Perl f win32-unicode-native-to-ascii.pl #### $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rename Windows files with Unicode chars
by mnooning (Beadle) on Aug 27, 2016 at 03:35 UTC | |
by beech (Parson) on Aug 27, 2016 at 03:44 UTC | |
by mnooning (Beadle) on Aug 27, 2016 at 20:23 UTC | |
|
Re^2: Rename Windows files with Unicode chars
by Anonymous Monk on Sep 01, 2016 at 17:08 UTC | |
by nikosv (Deacon) on Sep 02, 2016 at 04:32 UTC | |
|
Re^2: Rename Windows files with Unicode chars
by dpoppi (Initiate) on Jan 18, 2017 at 07:22 UTC | |
by beech (Parson) on Jan 18, 2017 at 07:35 UTC | |
by Athanasius (Archbishop) on Jan 18, 2017 at 07:52 UTC |