I do this on Ruby 1.9 when I want everything to be in UTF-8:
if filename.encoding.to_s != 'UTF-8' filename.encode!('UTF-8') end
If your OS does not give a file name encoded by an encoding system that does not support some special characters found in the file name, it can be encoded in UTF-8 without hickup.
source share