Dan Stutzman

How to make Ruby 1.9.2 list Unicode filenames in Windows

Published 2011-04-09

Running the following Ruby code on Windows appears to convert non-ANSI characters in filenames into question marks, even on Ruby 1.9.2 where the problem was supposed to be fixed:

p Dir.entries('.')

Apparently there's a currently undocumented parameter added to Dir.entries in Ruby 1.9.2 that you can pass in to fix this:

p Dir.entries('.', :encoding => 'UTF-8')

Thanks to gmags on Stack Overflow for this tip.