Wolfgang Nasi-Donner wrote:

> "Peter C" <pkchau / gmail.com> schrieb im Newsbeitrag
> news:2c9220c5.0503150920.6eedfbc9 / posting.google.com...
> 
>>I'm working with Japanese character sets in Windows. I can save my
>>*.rb files with notepad using UTF-8 but I can't run them with Ruby.
>>This is what happens when I try to run it.
>>
>>c:\> ruby -Ku myFile.rb
>>jpn.rb:1: undefined method `&#8745;&#9559;&#9488;' for main:Object
>>(NoMethodError)
>>
> The Windows-Editor writes always a "Byte Order Mark" (BOM) at the beginning
> of UTF-8/16LE/16BE coded files. In this case a UTF-8 coded file begins with
> "EF BB BF" (hex). These non-characters should usually be ignored (for more
> information see http://www.unicode.org/).
> 
> One possibility is to remove the first three bytes of the UTF-8 encoded file
> using some filter program or a hex editor. You should do this into a copy,
> because the Windows editor cannot work correctly on this changed data :-((

Another one is to have an assignment to a scratch variable at the 
beginning of the script. Ruby will parse the BOM as the part of the 
variable name and thus not complain about it.

I've posted this to ruby-core a few months ago and would like to see it 
fixed...