Friday, May 6, 2011

can Ruby get the filenames in a folder if they have Unicode characters (on Windows Vista)?

i was writing a script on Windows Vista to move the files in a folder to another hard drive, but found that Ruby 1.8.6 or 1.9 both would get back filenames with Unicode characters in it replaced by "??????"

so for example, the filename "Chart for ???????.doc" is returned

so the file cannot be moved at all...

i used

filename.each_byte {|x| p x}

to make sure it is internally really "?" characters inside the string, not just when it is printed out.

From stackoverflow


Post a Comment