Original post is http://jira.codehaus.org/browse/JRUBY-2677 , when problems goes deeper, this issue is created.
All files involved in WinXP is encoded in GB2312, and all files involved in Linux is encoded in UTF-8.
My WinXP uses GB2312 as locale, and my Linux uses UTF-8 as locale.
[Dice@localhost lib]$ cat test.rb
puts ARGV[0]
puts '中文字符串'
IO.foreach(ARGV[0])
{|line| puts line}
[Dice@localhost lib]$ cat txt_en
English string from text file.
中文字符串来自text文件。
[Dice@localhost lib]$ cat txt_中文
English string from text file.
中文字符串来自text文件。
[Dice@localhost lib]$ java -jar jruby.jar -v
ruby 1.8.6 (2008-05-28 rev 6586) [i386-jruby1.1.2]
[Dice@localhost lib]$ java -jar jruby.jar test.rb txt_en
txt_en
中文字符串
English string from text file.
中文字符串来自text文件。
[Dice@localhost lib]$ java -jar jruby.jar test.rb txt_中文
txt_??
中文字符串
test.rb:3:in `initialize': No such file or directory - File not found - txt_?? (Errno::ENOENT)
from test.rb:3:in `foreach'
from test.rb:3
This error comes from the fact that jruby1.1.2 can't process arguments containing Chinese charactors correctly.
This bug is reported in Issue JRUBY-2677, and Charles Oliver Nutter fixed it.
[Dice@localhost lib]$ java -jar jruby.jar -v
jruby 1.1.3-dev (ruby 1.8.6 patchlevel 114) (2008-07-16 rev 7193) [i386-java]
[Dice@localhost lib]$ java -jar jruby.jar test.rb txt_en
txt_en
中文字符串
English string from text file.
中文字符串来自text文件。
[Dice@localhost lib]$ java -jar jruby.jar test.rb txt_中文
txt_中文
中文字符串
English string from text file.
中文字符串来自text文件。
It becomes OK because the locale of my Linux is UTF-8.
But when I tried it under WinXP whose locale is GB2312, deeper problems occured.
F:\MyStudio\jruby-1.1.2\bin>jruby.bat -v
jruby 1.1.3-dev (ruby 1.8.6 patchlevel 114) (2008-07-16 rev 7193) [x86-java]
F:\MyStudio\jruby-1.1.2\bin>jruby.bat test.rb txt_中文
txt_中文
中文字符串
test.rb:3:in `initialize': No such file or directory - File not found - txt_????
(Errno::ENOENT)
from test.rb:3:in `foreach'
from test.rb:3
Charles Oliver Nutter's explanation is overhere http://jira.codehaus.org/browse/JRUBY-2677?focusedCommentId=142123#action_142123
Afer this weekend I'll have my summer holiday for more than one month, during which I will not be able to surf the Internet, so I can't view and post comments on this issue.
And I'm just a Chinese college student who is just a beginner in programing, so I can't help you too much in fact.
Well, when I return I will see what had happend.
Good luck!
In order to get encoding, we can use system property. Please try this patch.