nonopolarity
nonopolarity

Reputation: 150976

Can Ruby get the filenames in a folder if they have Unicode characters?

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, and 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.

Upvotes: 0

Views: 557

Answers (1)

MickaelFM
MickaelFM

Reputation: 907

Ruby supports utf8, but not multibyte. You have to use third libraries as http://ruby-unicode.rubyforge.org/doc/

Upvotes: 1

Related Questions