views:

165

answers:

2

I have a script running on Ruby 1.9.1 on Windows 7

I've distilled my script down to

File.open("翻譯測試.txt")

and still can't get it to work. I know there are issues with Ruby 1.9 filename handling on windows (Using the Windows ANSI library), but would be happy enough with a work around that is callable from Ruby

+1  A: 

Hello,

Most of the Unicode changes like file and directory operations have been improved in 1.9.2 (trunk) and other bigger changes will be merged pretty soon.

As bobince pointed out, this was already asked:

http://stackoverflow.com/questions/2703283/unicode-filenames-on-windows-in-ruby

Luis Lavena
A: 

This should help you string = "翻譯測試" # by default, string is encoded as "ASCII" string.force_encoding("SHIFT-JIS") # retags the String as SHIFT-JIS or whatever UTF char set that #is in

Heres a nice read a bit about char encoings in 1.9.1

http://yehudakatz.com/2010/05/17/encodings-unabridged/

Jet Abe