I am afraid to work with a path containing non-English characters (Activestate Perl, Windows XP). How to open, write, copy, etc. A file located along the path, indicating, for example, Greek / Russian / French accent symbols? Let's say the directory in which I want to copy the text.txt file is:C:\Documents and Settings\στα\Desktop
C:\Documents and Settings\στα\Desktop
use File::Spec; my $save = File::Spec->canonpath( $mw->chooseDirectory() ); my $file = catfile($save , "renamed_text.txt"); my $input = "üüü\text.txt"; copy ($input, $file) or die "File cannot be copied.";
( PAR Shift-JIS). , Perl 5.8 . , , , .
:
use Encode; use Win32::Codepage; my $encoding = Win32::Codepage::get_encoding() || q{}; if ($encoding) { $encoding = Encode::resolve_alias($encoding) || q{}; } sub encode_filename { my ($filename) = @_; return $encoding ? encode($encoding, $filename) : $filename; }
next if (! -d encode_filename($tmpldir)); my $file = SWF::File->new(encode_filename($dest)); @entries = File::Slurp::read_dir(encode_filename($srcdir)); etc...
, , !
egrep "\-[a-zA-Z] |open[^_]|[^ ]parse|unlink|symlink|mkdir[^_]|mkpath|rename[^\']|File::Copy::copy|rmtree|getTemplate[^D]|write_file|read_file|read_dir" *.pl `find lib -name '*.pm'` | grep - v encode_filename | egrep -v '^[^:]+: *(\#|_announce|debug)'
, "Wide-character" ...
, , , , , Win32:: Codepage.
, , , , Perl UTF8 , ASCII. Linux OS X , UTF8. Windows (pre Windows 7?) (, Shift-jis , ). , Perl, , ASCII, .
, , Win32: Codepage, UTF8 . , ( ) , .
Perl. Win32, Unicode. Win32 perl v5.8.7.
Win32
, UAC (User Access Control) Microsoft Windows Vista, Win32::Locale, Win32::Codepage. (, , .)
Win32::Locale
Win32::Codepage
I also had problems with UAC (User Access Control) in Windows 7 and later. Finally, I found out that access to the desired registry key has only read permissions from WIndows Vista. You can easily install Win32 :: Codepage to work without administrative privileges if you open the file in your favorite editor and replace:
$codekey = Win32::TieRegistry->new($CODEPAGE_REGISTRY_KEY, { Delimiter => "/" } ); $codekey = Win32::TieRegistry->new($CODEPAGE_REGISTRY_KEY, { Access=>"KEY_READ", Delimiter => "/" } );
This helped in my installation.