The Problem isn’t reading the file but opening it…! The program throws
an exception if, for instance, you try to drop the file in the attached
zip onto it.
My program will read in mp3-files and examine them with id3lib-ruby, so
I don’t have influence on the file’s contents anyway.
The Problem isn’t reading the file but opening it…! The program throws
an exception if, for instance, you try to drop the file in the attached
zip onto it.
OK - it helps if you post the error message you get so we can see what’s
going wrong.
I have a file whose name has accented characters, and it works fine for
me (Ruby 1.8, 1.9, OS X, wxRuby 2.0.0). Can you say what platform and
version of wxRuby you’re using?
I’m working on XP-Home, SP3. German locales
ruby -v: ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
On Windows, file names aren’t encoded in UTF-8, but in a local encoding
(for me, and probably you, CP1252). So the filename returned by wxRuby
doesn’t exist.
I think we should fix this so that wxRuby methods that accept or return
file paths return those strings in an encoding that can be passed
straight to Ruby’s File/Dir methods.
In the meantime, you can work around this by manually converting the
filepaths to the correct encoding before opening them:
require ‘iconv’ # at the top of your script
files.each do | file |
if Wx::PLATFORM == ‘WXMSW’
file = Iconv.conv(‘CP1252’, ‘UTF-8’, file)
end
… process file as normal
end
I’m working on XP-Home, SP3. German locales
ruby -v: ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
On Windows, file names aren’t encoded in UTF-8, but in a local encoding
(for me, and probably you, CP1252). So the filename returned by wxRuby
doesn’t exist.
I think we should fix this so that wxRuby methods that accept or return
file paths return those strings in an encoding that can be passed
straight to Ruby’s File/Dir methods.
In the meantime, you can work around this by manually converting the
filepaths to the correct encoding before opening them:
require ‘iconv’ # at the top of your script
files.each do | file |
if Wx::PLATFORM == ‘WXMSW’
file = Iconv.conv(‘CP1252’, ‘UTF-8’, file)
end
… process file as normal
end
I’m working on XP-Home, SP3. German locales
ruby -v: ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
gem list wxruby: wxruby (2.0.0, 1.9.9)
Looking forward to your answer,
Christian.
Alex F. wrote:
Christian Schmidt wrote:
The Problem isn’t reading the file but opening it…! The program throws
an exception if, for instance, you try to drop the file in the attached
zip onto it.
OK - it helps if you post the error message you get so we can see what’s
going wrong.
I have a file whose name has accented characters, and it works fine for
me (Ruby 1.8, 1.9, OS X, wxRuby 2.0.0). Can you say what platform and
version of wxRuby you’re using?
alex
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.