fanticla has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
Probably my question has been already answered, but I didn't find any solution.
Here is the problem: Working on a Windows machine, how can I open a file if its path has characters with accents? I get the path using getOpenFile. Here is what I do.
sub convert_ansi_to_utf { my $types = [ ['Text', '.txt'], ['All Files', '*'],]; my $filename= $frame_kwic_setup->getOpenFile(-filetypes => $types); open(F, "<:encoding(iso-8859-1)", "$filename") or die $!; open(G, ">:utf8", "$filename.utf.txt") or die $!; while (<F>) { print G } close (F); close (G); }
It is a simple subrutine to convert a textfile from ANSI to UTF-8. If the path is for example:
C:\Documents and Settings\AA\Documents\Data\Examples\Università\AS 2010\text.txt
I get an error, file could not be found. Anyone has an Idea how to solve the problem? Thanks. C.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dos path accents
by Anonymous Monk on Oct 22, 2010 at 08:32 UTC | |
by fanticla (Scribe) on Oct 22, 2010 at 08:58 UTC | |
by Anonymous Monk on Oct 22, 2010 at 09:19 UTC | |
by Jim (Curate) on Oct 22, 2010 at 18:06 UTC | |
by Anonymous Monk on Oct 23, 2010 at 06:43 UTC | |
|